필터 지우기
필터 지우기

Unable to read FITS file in Matlab but ImageJ(Fiji) is able to read it

조회 수: 5 (최근 30일)
Ajay Gunalan
Ajay Gunalan 2023년 11월 10일
이동: Walter Roberson 2023년 11월 11일
My Fits File1: Link
My Fits File2: Link
Debug
fitsinfo('surfaceFull.fits')
Output
Output argument "precision" (and possibly others) not assigned a value in the execution with "fitsinfo>bitdepth2precision"
function.
Error in fitsinfo>updateInfoForPrimary (line 353)
info(1).DataType = bitdepth2precision(value);
Error in fitsinfo>readheaderunit (line 291)
info = updateInfoForPrimary(info);
Error in fitsinfo (line 220)
info.PrimaryData = readheaderunit(fid, info.FileSize);
My Code
clear all; close all; clc;
%% Read and display a FITS file in MATLAB
filePath = 'data\getDepthFromSparse3Doct\surfaceFull.fits';
data = fitsread(filePath);
figure;
imagesc(data); % This function scales the display based on the range of data values
colorbar; % Adds a colorbar to the figure
title('Display of FITS File Data');
axis image; % Sets the aspect ratio so that data units are the same in every direction
Output
Output argument "precision" (and possibly others) not assigned a value in the execution with "fitsinfo>bitdepth2precision"
function.
Error in fitsinfo>updateInfoForPrimary (line 353)
info(1).DataType = bitdepth2precision(value);
Error in fitsinfo>readheaderunit (line 291)
info = updateInfoForPrimary(info);
Error in fitsinfo (line 220)
info.PrimaryData = readheaderunit(fid, info.FileSize);
Error in fitsread (line 103)
info = fitsinfo(filename);
Error in depthMapReconstrcution (line 4)
data = fitsread(filePath)

답변 (2개)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2023년 11월 10일
Just looking at the ImageJ imported images from the two FITS files, two points can be made:
(1) FITS image data file is not complete
image(imread('surfaceFull.png'))
(2) FITS image data is in 32-bit, and hence, bit size precision issue is prompted.

Walter Roberson
Walter Roberson 2023년 11월 11일
이동: Walter Roberson 2023년 11월 11일
The first fits file (at least) consistently is empty in columns 9 and 10, and then starts columns 11 and 12 with '= ' . That appears at the moment to be acceptable to the definitions at https://archive.stsci.edu/fits/fits_standard/node29.html#SECTION00912200000000000000 but on the other hand https://archive.stsci.edu/fits/fits_standard/node39.html#SECTION00941120000000000000 says that for BITPIX that the value field must contain an integer...
Ummmm, let me think...
I suspect there might possibly be no contradiction in the definitions if columns 9 and 10 are empty but columns 11 and 12 do not start with '= ' -- if the value appears directly.
In any case the code in fitsinfo function getValueAndComment is treating the rest of the BITPIX line as a comment. Regardless of whether that is right or wrong, that is the difficulty of the file: that in the primary header, columns 9 and 10 are expected to be '= ' and columns 11 onwards are expected to be the numeric value, whereas in the actual file, columns 9 and 10 are blank and columns 11 and 12 contain '= ' and then there is a value after that.

Community Treasure Hunt

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

Start Hunting!

Translated by