addisonElliott/matn​rrd

版本 1.0.1 (18.8 KB) 作者: Addison Elliott
MATLAB library that provides easy-to-use functions for loading and saving NRRD files.
201.0 次下载
更新时间 2018/8/16

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

引用格式

Addison Elliott (2024). addisonElliott/matnrrd (https://github.com/addisonElliott/matnrrd), GitHub. 检索来源 .

MATLAB 版本兼容性
创建方式 R2015a
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 Cell Arrays 的更多信息

Community Treasure Hunt

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

Start Hunting!

无法下载基于 GitHub 默认分支的版本

版本 已发布 发行说明
1.0.1

Add support for custom fields in nrrdread and nrrdwrite

1.0.0.0

要查看或报告此来自 GitHub 的附加功能中的问题,请访问其 GitHub 仓库
要查看或报告此来自 GitHub 的附加功能中的问题,请访问其 GitHub 仓库