gcsharp
(Greg Sharp)
February 7, 2018, 8:47pm
1
Hi, I’m trying to use nrrdwrite.m to create nrrds, but it doesn’t work on 2D images. Does anyone know if/how in Octave I can convert these to 3D images with one voxel in the 3rd dimension?
Alternatively, I can submit a patch to nrrdwrite, if such an interpretation is desirable.
pieper
(Steve Pieper (Isomics, Inc.))
February 7, 2018, 9:03pm
2
I think they will need to be one slice 3d nrrd files.
lassoan
(Andras Lasso)
February 7, 2018, 9:59pm
3
I’ve updated this nrrdwrite function to be able to save 2D image (as single-slice 3D volume):
function nrrdwrite(outputFilename, img)
% Write image and metadata to a NRRD file (see http://teem.sourceforge.net/nrrd/format.html)
% img.pixelData: pixel data array
% img.ijkToLpsTransform: pixel (IJK) to physical (LPS, assuming 'space' is 'left-posterior-superior')
% coordinate system transformation, the origin of the IJK coordinate system is (1,1,1) to match Matlab matrix indexing
% img.metaData: Contains all the descriptive information in the image header. The following fields are ignored:
% sizes: computed to match size of img.pixelData
% type: computed to match type of img.pixelData
% kinds: computed to match dimension of img.pixelData
% dimension: computed to match dimension of img.pixelData
% space_directions: ignored if img.ijkToLpsTransform is defined
% space_origin: ignored if img.ijkToLpsTransform is defined
% img.metaData: Contains the list of full NRRD field names for each
% metaData field name. All fields should be listed here that have a
% special character in their name (such as dot or space).
% img.metaDataFieldNames: Contains full names of metadata fields that cannot be used as Matlab field names because they contains
% special characters (space, dot, etc). Full field names are used for determining the field name to be used in the NRRD file
% from the Matlab metadata field name.
%
% Supports writing of 3D and 4D volumes.
This file has been truncated. show original
1 Like
gcsharp
(Greg Sharp)
February 7, 2018, 10:57pm
4
Works great. Thanks!
I suggest a tiny little change: line 76 would benefit from a semi-colon!
1 Like
lassoan
(Andras Lasso)
February 10, 2018, 8:13pm
5
Thank you, I’ve fixed it.