Dear All,
I have the pointclass3.lmf file as attached. But I dont know how to open it. In manual just said like below:
"This routine saves information about the photon history in a binary list mode file. The file will have the extension *.lmf. To save disk space, each record of a history in the binary file will have nine 16-bit integer values, one 64-bit float value, and one 8-bit value in the order indicated in the table. "
Anyone can hel me?

댓글 수: 8

Walter Roberson
Walter Roberson 2024년 11월 22일
DGM
DGM 2024년 11월 23일
편집: DGM 2024년 11월 23일
I have no idea what the file is, but maybe this is a start.
% i'm assuming byte order and signedness of integer classes
% is there a header? file length is not integer-divisible by described record length
% i'm assuming that the data is not compressed, and that the there is nothing trailing the data
% that assumption leaves _at least_ 16B that can't be data.
fid = fopen('pointclass3.lmf');
stream = fread(fid,inf,'*uint8');
fclose(fid);
recordlen = 18 + 8 + 1; % 9x16b, 1x64b, 1x8b
headerlen = mod(numel(stream),recordlen); % is there a header??
header = stream(1:headerlen);
data = reshape(stream(headerlen+1:end),recordlen,[]);
% the 16b fields
fields1 = typecast(reshape(data(1:18,:),[],1),'uint16');
fields1 = reshape(fields1,9,[]).';
% the double float field
fields2 = typecast(reshape(data(19:26,:),[],1),'double');
% the 8b field (the recasting here is redundant, but i'm just being explicit)
fields3 = typecast(reshape(data(23,:),[],1),'uint8');
In the case of blindly decoding physical images, there's often some discernable structure that tells us if we're decoding things grossly wrong. With tabular data, we don't really get the same insight. The results can be completely wrong, and I would have no idea.
EDIT: My blind suggestion is probably garbage. This is probably closer, since you seem to be doing a lot of medical image stuff.
That suggests though, that each LMF file should have a text file which describes its structure -- something like a header file. This is at odds with my assumption that the LMF file itself apparently must have had a header due to its length.
Cris LaPierre
Cris LaPierre 2024년 11월 23일
Can you share the table the quoted text refers to?
mohd akmal masud
mohd akmal masud 2024년 11월 23일
편집: Walter Roberson 2024년 11월 23일
I think there is file image produced together. You can get the file image as link here: https://drive.google.com/drive/folders/18f_e3KljFuebeQHH6KRVXHbCyRx_0Moq?usp=sharing .
pointlmf.a00 = the image file
pointlmf.h00 = the header file image
pointlmf.lmf = saves information about the photon history in a binary list mode file.
Actually the lmf file accordingly to manual is saves information about the photon history in a binary list mode file. The manual just said like below:
DGM
DGM 2024년 11월 23일
편집: DGM 2024년 11월 23일
Yee. Well, as much as that looks helpful, I'm not able to download 1.3GB in a reasonable timeframe.
The screenshot does, however tell us that there's an extra field. With that information, the file does appear to have an integer number of records.
fid = fopen('pointclass3.lmf');
stream = fread(fid,inf,'*uint8');
fclose(fid);
recordlen = 20 + 8 + 1; % 10x16b, 1x64b, 1x8b
headerlen = mod(numel(stream),recordlen) % is there a header??
header = stream(1:headerlen);
data = reshape(stream(headerlen+1:end),recordlen,[]);
% the 16b fields
xyz0 = typecast(reshape(data(1:6,:),[],1),'uint16');
xyz0 = reshape(xyz0,3,[]).';
xyzphantom = typecast(reshape(data(7:12,:),[],1),'uint16');
xyzphantom = reshape(xyzphantom,3,[]).';
xyzcrystal = typecast(reshape(data(13:18,:),[],1),'uint16');
xyzcrystal = reshape(xyzcrystal,3,[]).';
energy = typecast(reshape(data(19:20,:),[],1),'uint16');
% the double float field
photonweight = typecast(reshape(data(21:28,:),[],1),'double');
% the 8b field
scatterorder = typecast(reshape(data(29,:),[],1),'uint8');
mohd akmal masud
mohd akmal masud 2024년 11월 23일
Dear @DGM
I was try your syntax. All is well.
But the value in workspace I dont know what is it actually?
Is it is images? is it is data? is it is graph profile?
Can you help me how to view all that valu workspace?
Dear @DGM,
headerlen = mod(numel(stream),recordlen) % is there a header??
The header files is attached.

댓글을 달려면 로그인하십시오.

 채택된 답변

Harsh
Harsh 2024년 11월 24일

0 개 추천

Hi Akmal,
You can use “fread” function to read a binary file in MATLAB. Below is the code to read data in the format mentioned by you.
% Open the file in binary read mode
fileID = fopen('pointclass3.lmf', 'rb');
numRecords = 10; % As an example we read 10 records
% Preallocate arrays to store data
int16Data = zeros(numRecords, 9, 'int16'); % 9 int16 values per record
float64Data = zeros(numRecords, 1, 'double'); % 1 float64 value per record
int8Data = zeros(numRecords, 1, 'int8'); % 1 int8 value per record
% Loop to read each record
for i = 1:numRecords
int16Data(i, :) = fread(fileID, 9, 'int16'); % Read 9 int16 values
float64Data(i) = fread(fileID, 1, 'double'); % Read 1 float64 value
int8Data(i) = fread(fileID, 1, 'int8'); % Read 1 int8 value
end
% Close the file
fclose(fileID);
% Display the first record as an example
disp('First Record:');
disp('Int16 Data:');
disp(int16Data(1, :));
disp('Float64 Data:');
disp(float64Data(1));
disp('Int8 Data:');
disp(int8Data(1));
Here’s the output for the above code-
You may refer to the following documentation to learn more about “fread” function - https://www.mathworks.com/help/matlab/ref/fread.html

추가 답변 (0개)

제품

릴리스

R2023b

질문:

2024년 11월 22일

답변:

2024년 11월 24일

Community Treasure Hunt

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

Start Hunting!

Translated by