Medical image header character fail
1 次查看(过去 30 天)
显示 更早的评论
So I have a medical image header that has a problem which for some reason I can not seem to fix.
The header is a struct with a field 'voxel_order'. This medical image I have to put in another analysis tool which uses this field as an input. Now, I have a working and a failing header:
Working header -> voxel_order = 1x4 char -> 'RAS ' (in variables tab there is a space-like, empty char on the 4th index)
Failing header -> voxel_order = 1x4 char -> 'LAS' (there is no empty char on 4th index)
The problem is like this, the analysis software needs an "empty" 4th character to work but for some reason this cant be just an ' '.
The following things fail:
adding an empty 4th character by just adding ' ' (it then also becomes 'LAS ' instead of 1x4 char in struct value description)
adding it via char('L','A'.. etc (it then also becomes 'LAS ' instead of 1x4 char in struct value description)
The following thing works:
copying the voxel_order from the working header and changing the 1st index char with voxel_order(1)='L'
Error it gives (analysis software is python based): ValueError: Not all axis codes ['L', 'A', 'S', ' '] in label set ['L', 'R', 'P', 'A', 'I', 'S', None]
I want to be able to fix this on its own and not need to import a working header and copy from that every time. It should also not be too hard of a problem but I just cant seem to fix it. Thanks in advance!
0 个评论
回答(1 个)
Pratyush
2023-12-19
Hi Boaz,
I understand that the analysis software you are using is expecting a 4-character array where the fourth character is not just a space, but a specific type of whitespace or non-printing character that is not being replicated when you simply add a space using ' '.
In MATLAB, you can try creating a 4-character array where the fourth character is a different type of whitespace, such as a non-breaking space (char(160)) or another non-printing character that might be interpreted as "empty" by the analysis software.
Here's how you can try setting the "voxel_order" field with different types of whitespace characters:
% Your failing header struct
header.failing.voxel_order = 'LAS';
% Option 1: Try adding a non-breaking space (ASCII 160)
header.failing.voxel_order(4) = char(160);
% Option 2: Try adding a null character (ASCII 0)
header.failing.voxel_order(4) = char(0);
% Option 3: Try adding a horizontal tab (ASCII 9)
header.failing.voxel_order(4) = char(9);
% Check if the voxel_order is now a 1x4 char
disp(header.failing.voxel_order);
The error message you're seeing from the Python-based analysis software suggests that it's expecting a set of axis codes that includes None for the fourth character, which might be interpreted as a null character or some other non-printing character in Python.
Remember to save the header after modification if needed, so that you can use it with the analysis software.
2 个评论
Image Analyst
2023-12-19
If this Answer solves your original question, then could you please click the "Accept this answer" link to award the answerer with "reputation points" for their efforts in helping you? They'd appreciate it. Thanks in advance. 🙂 Note: you can only accept one answer (so pick the best one) but you can click the "Vote" icon for as many Answers as you want. Voting for an answer will also award reputation points.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!