Parse file (*.ct.img) containing projection dataset to access individual CT projections

1 次查看(过去 30 天)
Hi,
I have a (*.ct.img) file from a CT scan (siemens Inveon). The file contains projection data set. I would like to access the projection data set or individual projections, however, the file seems to be encrypted. Is there any way I can access and store projection images separately?
my code is as:
filepath = '/Volumes/Elements/rawDataSet/2023-12-07_144401_ST2/2023-12-07_144401_ST2_XST_CTnoContrast1bed38mm_v1_OSEM_DS4_Slight.ct.img';
% Specifing the dimensions
numRows = 256; numCols = 256;
fid = fopen(filepath, 'rb');
rawData = fread(fid, inf, 'single');%reading binary data into a single aray
fclose(fid);
imageData = reshape(rawData, [], numCols);%Reshaping
After reshaping I have 32768X256 double. I assume I need to breakdown the imageData further. Any tips on how to proceed will be greatly appreciated.

采纳的回答

Aditya
Aditya 2024-1-24
Hi Abhisek,
Given that you've already read the file into a variable called rawData and reshaped it into a matrix imageData with 32768 rows and 256 columns, it seems that you might need to further reshape the data to match the actual dimensions of the individual projections.
Here's a step-by-step approach to help you proceed:
  1. Determine the Number of Projections: You'll need to know how many projections are included in the file. This information is sometimes provided in accompanying metadata files or documentation.
  2. Reshape the Data: Once you know the number of projections, you can reshape the data into a 3D array where the dimensions correspond to the number of rows and columns of each projection image and the number of projections.
  3. Extract Individual Projections: After reshaping the data into a 3D array, you can access individual projections by indexing into the array.
Here's how you might modify your code to include these steps:
filepath = '/Volumes/Elements/rawDataSet/2023-12-07_144401_ST2/2023-12-07_144401_ST2_XST_CTnoContrast1bed38mm_v1_OSEM_DS4_Slight.ct.img';
numRows = 256;
numCols = 256;
% You need to know the number of projections to proceed
numProjections = 128;
fid = fopen(filepath, 'rb');
rawData = fread(fid, inf, 'single'); % Reading binary data into a single array
fclose(fid);
% Reshape rawData into a 3D array (numRows x numCols x numProjections)
imageData = reshape(rawData, [numRows, numCols, numProjections]);
% Now you can access individual projections
% For example, to access the first projection:
firstProjection = imageData(:, :, 1);
% Display the first projection
imagesc(firstProjection);
colormap('gray');
axis('image');
% To save individual projections as separate image files
for i = 1:numProjections
projection = imageData(:, :, i);
imwrite(uint8(projection), sprintf('projection_%03d.png', i));
end
Please note that the number of projections (numProjections) we have mentioned assumes that size of each projection is 256*256. If this is not correct, you will need to find the correct value based on the file's documentation or metadata. Also, the uint8 conversion is used for saving the images. If your data has a higher dynamic range, you might need to use a different data type such as uint16 or adjust the scaling accordingly.
For more information on the "imagesc" and "imwrite" functions, refer to the MATLAB documentation:
Hope this helps!
  1 个评论
Abhisek
Abhisek 2024-1-26
Hi Aditya,
Thank you for your help. The code you added executed. However, after I changed the number of projections to 361 (according to metadata) the code is not working. Probably I might need to resize the matrix further. I have added the metadata for your reference.
-Abhisek
usTotalSlicesInVol 1024
usSampPerProj 1024
usNumProj 361
fStartAngle 0
fStopAngle 360

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Scripts 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by