addisonElliott/matn​rrd

MATLAB library that provides easy-to-use functions for loading and saving NRRD files.
200 Downloads
Aktualisiert 16 Aug 2018

matnrrd is a MATLAB library that provides easy-to-use functions for loading and saving NRRD files. One feature that sets matnrrd apart from other NRRD readers is that it parses the metadata fields into sensible datatypes.
To use this library, copy/paste nrrdread.m and nrrdwrite.m somewhere in your MATLAB path. You are ready to go!

Examples:

[data, metadata] = nrrdread('data/test1d_ascii.nrrd');
[data, metadata] = nrrdread('data/test3d_bigendian_raw_noendianfield.nrrd', 'Endian', 'big');

[data, metadata] = nrrdread('data/test1d_ascii.nrrd');
metadata.encoding = 'raw';
nrrdwrite('test.nrrd', data, metadata);

METADATA

One of the main advantages of this function is that the metadata is
parsed from strings and turned into a sensible datatype. This is
performed for the fields specified in the NRRD specification.

A structure is used to store the metadata fields in MATLAB. One caveat
of using a structure is that the keys cannot have spaces in them.
Since the NRRD format includes fields with spaces, the spaces are
removed when reading. A fieldMap key is added to the structure that
contains a Nx2 cell array. The first column signifies the key name in
the MATLAB metadata structure and the second column contains the actual
field name with spaces. This preserves the spaces in field names when
using nrrdwrite to save an NRRD file.

Here is a list of supported fields and their corresponding MATLAB
datatype they are converted to:
* dimension - int [REQUIRED]
* lineskip - int
* byteskip - int
* space dimension - int
* min - double
* max - double
* oldmin - double
* oldmax - double
* type - string [REQUIRED]
* endian - string
* encoding - string [REQUIRED]
* content - string
* sampleunits - string
* datafile - string
* space - string
* sizes - 1xN matrix of ints [REQUIRED]
* spacings - 1xN matrix of doubles
* thicknesses - 1xN matrix of doubles
* axismins - 1xN matrix of doubles
* axismaxs - 1xN matrix of doubles
* kinds - Nx1 cell array of strings
* labels - Nx1 cell array of strings
* units - Nx1 cell array of strings
* spaceunits - Nx1 cell array of strings
* centerings - Nx1 cell array of strings
* spacedirections - MxN matrix of doubles
* spaceorigin - MxN matrix of doubles
* measurementframe - MxN matrix of ints

Most of the fields listed in the table above are optional with the
exception of four. The NRRD file must contain the type, dimension,
sizes and encoding fields.

Note: For spacedirections, NRRD allows specifying none for a
particular dimension to indicate it is not a spatial domain.
NRRDREAD will make the first row of the matrix all NaN's to signal
that it is none for the dimension. For example:
space directions: none (1,0,0) (0,1,0) (0,0,1)
will turn into:
[NaN NaN NaN; 1 0 0; 0 1 0; 0 0 1]

For unsupported fields, a warning will be displayed and the value will
be left as a string.

Help out by reporting bugs or contributing code at:
https://github.com/addisonElliott/matnrrd

See the format specification online:
http://teem.sourceforge.net/nrrd/format.html

Zitieren als

Addison Elliott (2024). addisonElliott/matnrrd (https://github.com/addisonElliott/matnrrd), GitHub. Abgerufen .

Kompatibilität der MATLAB-Version
Erstellt mit R2015a
Kompatibel mit allen Versionen
Plattform-Kompatibilität
Windows macOS Linux
Kategorien
Mehr zu Cell Arrays finden Sie in Help Center und MATLAB Answers

Community Treasure Hunt

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

Start Hunting!

Versionen, die den GitHub-Standardzweig verwenden, können nicht heruntergeladen werden

Version Veröffentlicht Versionshinweise
1.0.1

Add support for custom fields in nrrdread and nrrdwrite

1.0.0.0

Um Probleme in diesem GitHub Add-On anzuzeigen oder zu melden, besuchen Sie das GitHub Repository.
Um Probleme in diesem GitHub Add-On anzuzeigen oder zu melden, besuchen Sie das GitHub Repository.