Dear all,
I have .nhdr file. as attched
Anyone can help me to open it?

 Accepted Answer

DGM
DGM on 16 Jul 2023
It's just text, but there's already tools to read these files specifically, either with or without the associated data file.
headerInfo = nhdr_nrrd_read('res.nhdr',false) % read the header by itself

4 Comments

yah,
headerInfo =
struct with fields:
content: 'res'
data: []
type: 'double'
dimension: 3
space: 'left-posterior-superior'
sizes: [135 135 74]
spacedirections: {'(3,0,0)' '(0,3,0)' '(0,0,3)'}
spacedirections_matrix: [3×3 double]
kinds: {'domain' 'domain' 'domain'}
endian: 'little'
encoding: 'raw'
spaceorigin: [3×1 double]
datafiles: {'data.raw'}
Dear @DGM, what i need is to display sizes: [135 135 74]
I tried this want using function nhdr_nrrd_write.m as attached, but got error:
headerInfo = nhdr_nrrd_write('res.nhdr', headerInfo, 'a.dcm');
%res.nhdr - my filne name
%a.dcm - my new file name that want to create
ERROR:
Error using assert
Sizes mismatch: [135 135 74 ] in headerInfo structure is not compatible with the size of the data array [0 0
].
Error in nhdr_nrrd_write (line 92)
assert(nrrd_size_check(size(headerInfo.data), headerInfo.sizes),...
The command I gave was to read only the header, but not the data. Notice that the data field in the struct is empty. If you have the data and want to read both, you'd do
headerInfo = nhdr_nrrd_read('res.nhdr',true) % read the data also
Dear @DGM,
But I got error
headerInfo = nhdr_nrrd_read('res.nhdr',true) % read the data also
Error using nhdr_nrrd_read
While reading detached header file res.nhdr:
detached data file number 1/1 (data.raw) could not be opened.
DGM
DGM on 16 Jul 2023
I don't know why it can't read the file. I'm not familiar with these tools, and the error message doesn't say why it failed.

Sign in to comment.

More Answers (0)

Categories

Products

Release

R2022b

Asked:

on 16 Jul 2023

Commented:

DGM
on 16 Jul 2023

Community Treasure Hunt

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

Start Hunting!