Select multiple frames from a single fits file

Hi,
I have a csv file and a fits file, I need to select multiple frames from the fits file based on the non-zero indices of a csv file. In the attached csv file, I need to select the 4th and 7th frame from the fits file, as it contains the non-zero values.Can someone help?
TIA

回答(1 个)

vals = csvread('Book4.csv');
frame_numbers = find(vals ~=0);
num_frame = length(frame_numbers);
frame_data = cell(num_frame,1);
for K = 1 : num_frame
frame_data{K} = fitsread('AppropriateFilenameGoesHere.fits', 'image', frame_numbers(K));
end

5 个评论

It is throwing the index value out of range error
You do not have multiple frames in your fits file. You have a single frame that is multidimensional.
csv_filename - 'Book4.csv';
fits_filename = 'AppropriateFilenameGoesHere.fits';
vals = csvread(csv_filename);
frame_numbers = find(vals ~=0);
num_frame = length(frame_numbers);
finfo = fitsinfo(fits_filename);
imdims = finfo.Image.Size;
frame_data = zeros(imdims(1), imdims(2), num_frame);
for K = 1 : num_frame
frame_data(:,:,K) = fitsread(imdims, 'image', 'pixelregion', {[1 imdims(1)], [1 imdims(2)], frame_numbers(K)});
end
Thanks for your help. I'm new to MATLAB.
Getting an error:
Reference to non-exixtence field 'Image'.
Please show the content of the finfo variable .
It is a single file with 2600 frames.

请先登录,再进行评论。

类别

帮助中心File Exchange 中查找有关 File Operations 的更多信息

产品

版本

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by