MATLAB code for reading and writing CIFTI files, v2
==================================================================
This library is compatible with the CIFTI-2 format, without
externally installed dependencies (except that CIFTI-1 files require
wb_command for conversion), returning a structure that exposes the
information contained in the CIFTI-2 XML with minimal translation, as well
as the data matrix with no added padding. The cifti_read function is
the intended starting point, ciftiopen and similar are compatibility
wrappers so that the library can be used in older code.
Additionally, the library provides numerous helper functions to make many
common operations (such as extracting the data for one structure) into a
single line of intuitive code.
The previous code that was derived from FieldTrip is in the "ft_cifti"
folder.
The cifti structure returned by this library uses 0-based
indices for vertex and voxel indices, 1-based for cifti indices, and
the helper functions return 1-based indices for everything.
# Usage
All exposed functions have usage information available through the `help` command:
```
>> help cifti_read
function outstruct = cifti_read(filename, ...)
Read a cifti file.
...
```
The simplest practical usage is to load a cifti file with `cifti_read`, take
its data from the `.cdata` field, modify it, store it back into the `.cdata` field,
and write it back out to a new file with `cifti_write`:
```octave
mycifti = cifti_read('something.dscalar.nii');
mycifti.cdata = sqrt(mycifti.cdata);
cifti_write(mycifti, 'sqrt.dscalar.nii');
```
The `ciftiopen`, `ciftisave`, and `ciftisavereset` functions provide backward
compatibility with a previous cifti library (option II of
[HCP FAQ 2](https://wiki.humanconnectome.org/display/PublicData/HCP+Users+FAQ#HCPUsersFAQ-2.HowdoyougetCIFTIfilesintoMATLAB?)),
and you can also use this `ciftisavereset` function even if you use `cifti_read`.
An alternative way to do the equivalent of `ciftisavereset` is to use the
`cifti_write_from_template` helper function (which also has options to set
the names of the maps for dscalar, and similar for other cifti file types):
```octave
mycifti = cifti_read('something.dscalar.nii');
cifti_write_from_template(mycifti, mycifti.cdata(:, 1), 'firstmap.dscalar.nii', 'namelist', {'map #1'});
%ciftisavereset equivalent (keeping 'mycifti' unmodified):
mycifti = cifti_read('something.dscalar.nii');
newcifti = mycifti;
newcifti.cdata = mycifti.cdata(:, 1);
ciftisavereset(newcifti, 'firstmap.dscalar.nii');
clear newcifti;
```
The `cifti_struct_create_from_template` function can create a cifti struct without writing
it to a file, with the same options as `cifti_write_from_template` to control the other
diminfo. The `cifti_write...` or `cifti_struct...` functions should handle most cases of
working with common cifti files, including extracting the data for one cortical surface,
doing some computation on it, and replacing the surface data with the new values:
```octave
mycifti = cifti_read('something.dscalar.nii');
leftdata = cifti_struct_dense_extract_surface_data(mycifti, 'CORTEX_LEFT');
newleftdata = 1 - leftdata;
newcifti = cifti_struct_dense_replace_surface_data(mycifti, newleftdata, 'CORTEX_LEFT');
...
```
The `dense` part of some function names refers to only being applicable to "dense" files
or diminfo (in cifti xml terms, a "brain models" mapping), such as dtseries, dscalar,
dlabel, or dconn. There are more `dense` helpers mainly because there is a more common
need to make use of the information in a dense diminfo than most other diminfo types.
The `cifti_diminfo_*` helpers are lower-level and require more understanding of the
details of the cifti format, and often require writing more code to use them, so you
should generally look at the `cifti_write...` and `cifti_struct...` functions first.
# Function reference
## Main functions
### read/write and compatibility
```
outstruct = cifti_read(filename, ...)
cifti_write(cifti, filename, ...)
cifti = ciftiopen(filename, ...) %note: these 3 do not use option pairs,
ciftisave(cifti, filename, ...) % the varargin here is to make passing 'wb_command' optional
ciftisavereset(cifti, filename, ...)
```
### struct create helpers and write convenience functions
```
cifti = cifti_struct_create_from_template(ciftitemplate, data, type, ...)
cifti_write_from_template(ciftitemplate, data, filename, ...)
cifti = cifti_struct_create_sdseries(data, ...)
cifti_write_sdseries(data, filename, ...)
```
### dense struct extract/replace helpers
```
[outdata, outroi] = cifti_struct_dense_extract_surface_data(cifti, structure[, dimension])
cifti = cifti_struct_dense_replace_surface_data(cifti, data, structure[, dimension])
[outdata, outsform1, outroi] = cifti_struct_dense_extract_volume_all_data(cifti[, cropped, dimension])
cifti = cifti_struct_dense_replace_volume_all_data(cifti, data[, cropped, dimension])
[outdata, outsform1, outroi] = cifti_struct_dense_extract_volume_structure_data(cifti, structure[, cropped, dimension])
cifti = cifti_struct_dense_replace_volume_structure_data(cifti, data, structure[, cropped, dimension])
```
### misc
```
[surflist, vollist] = cifti_diminfo_dense_get_structures(diminfo) %returns the names of structures that exist in this diminfo
outstring = cifti_metadata_get(metadata, key) %returns empty string for nonexistent key
metadata = cifti_metadata_remove(metadata, key) %returns unmodified metadata struct for nonexistent key
metadata = cifti_metadata_set(metadata, key, value) %overwrites key if it exists
```
## Special usage
### advanced diminfo helpers
```
outinfo = cifti_diminfo_dense_get_surface_info(diminfo, structure)
outinfo = cifti_diminfo_dense_get_volume_all_info(diminfo[, cropped])
outinfo = cifti_diminfo_dense_get_volume_structure_info(diminfo, structure[, cropped])
outmap = cifti_diminfo_make_scalars(nummaps[, namelist, metadatalist])
outmap = cifti_diminfo_make_series(nummaps[, start, step, unit])
```
### advanced misc
```
indices = cifti_vox2ind(dims, voxlist1) %helper to act like sub2ind for voxel ijk lists
```
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
matlab算法,工具源码,适合毕业设计、课程设计作业,所有源码均经过严格测试,可以直接运行,可以放心下载使用。 Matlab(Matrix Laboratory)是一种专为数值计算和科学与工程应用而设计的高级编程语言和环境。在算法开发和实现方面,Matlab具有以下一些好处: 1. 丰富的数学和科学函数库:Matlab提供了广泛的数学、信号处理、图像处理、优化、统计等领域的函数库,这些函数库可以帮助开发者快速实现各种复杂的数值计算算法。这些函数库提供了许多常用的算法和工具,可以大大简化算法开发的过程。 2. 易于学习和使用:Matlab具有简单易用的语法和直观的编程环境,使得算法开发者可以更快速地实现和测试他们的算法。Matlab的语法与数学表达式和矩阵操作非常相似,这使得算法的表达更加简洁、清晰。 3. 快速原型开发:Matlab提供了一个交互式的开发环境,可以快速进行算法的原型开发和测试。开发者可以实时查看和修改变量、绘制图形、调试代码等,从而加快了算法的迭代和优化过程。这种快速原型开发的特性使得算法开发者可以更快地验证和修改他们的想法。 4. 可视化和绘图功能:Matlab具有强大的可视化和绘图功能,可以帮助开发者直观地展示和分析算法的结果。开发者可以使用Matlab绘制各种图形、曲线、图像,以及创建动画和交互式界面,从而更好地理解和传达算法的工作原理和效果。 5. 并行计算和加速:Matlab提供了并行计算和加速工具,如并行计算工具箱和GPU计算功能。这些工具可以帮助开发者利用多核处理器和图形处理器(GPU)来加速算法的计算过程,提高算法的性能和效率
资源推荐
资源详情
资源评论
收起资源包目录
用于读写CIFTI连接文件的MATLAB代码.zip (216个子文件)
miniz.c 221KB
xml_findstr.c 3KB
xml_findstr.c 3KB
zstream.c 2KB
LICENSE.fieldtrip 788B
LICENSE.gifti 767B
GPL 18KB
LICENSE 7KB
LICENSE 2KB
ft_read_header.m 90KB
ft_filetype.m 64KB
ft_read_cifti.m 39KB
ft_read_headshape.m 34KB
ft_write_cifti.m 31KB
cifti_parse_xml.m 28KB
ft_hastoolbox.m 26KB
ft_datatype_sens.m 20KB
getdimord.m 20KB
mvtk_write.m 18KB
ft_senstype.m 17KB
cifti_write_xml.m 17KB
xml_parser.m 16KB
xml_parser.m 16KB
ft_read_mri.m 16KB
xml_parser.m 15KB
ft_read_sens.m 14KB
ft_warp_apply.m 13KB
saveas.m 13KB
editor.m 12KB
editor.m 12KB
cifti_write.m 10KB
read_nifti2_hdr.m 10KB
ft_datatype.m 10KB
ft_convert_units.m 10KB
save.m 9KB
ft_scalingfactor.m 9KB
filetype_check_uri.m 9KB
read_yokogawa_header_new.m 9KB
read_ctf_hc.m 8KB
read_yokogawa_header.m 8KB
read_gifti_file_standalone.m 8KB
ft_warning.m 8KB
ft_write_headshape.m 7KB
cifti_read.m 7KB
refine.m 6KB
subsasgn.m 6KB
read_ply.m 6KB
find.m 6KB
read_bv_srf.m 6KB
read_neuromag_hc.m 6KB
ft_voltype.m 5KB
convert.m 5KB
find.m 5KB
read_nifti2_hdr.m 5KB
write_nifti2_hdr.m 5KB
base64encode.m 5KB
save.m 5KB
individual2sn.m 5KB
cifti_struct_create_from_template.m 5KB
save.m 5KB
read_stl.m 4KB
convert.m 4KB
attributes.m 4KB
ndgrid.m 4KB
write_nifti2_hdr.m 4KB
save_string.m 4KB
attributes.m 4KB
hasyokogawa.m 4KB
gifti.m 4KB
read_asa.m 4KB
add.m 4KB
ft_getopt.m 3KB
add.m 3KB
read_polhemus_fil.m 3KB
filetype_check_header.m 3KB
base64decode.m 3KB
write_ply.m 3KB
inflate_file.m 3KB
ft_struct2double.m 3KB
struct2xml.m 3KB
cifti_diminfo_dense_get_volume_all_info.m 3KB
isintent.m 3KB
read_caret_spec.m 3KB
cifti_struct_dense_replace_volume_structure_data.m 3KB
cifti_struct_dense_replace_volume_all_data.m 3KB
cifti_diminfo_dense_get_volume_structure_info.m 3KB
cifti_struct_dense_extract_volume_structure_data.m 2KB
tokenize.m 2KB
cifti_struct_dense_extract_volume_all_data.m 2KB
cifti_write_from_template.m 2KB
xmltree.m 2KB
sn2individual.m 2KB
ft_read_vol.m 2KB
getdimsiz.m 2KB
filetype_check_extension.m 2KB
cifti_struct_dense_replace_surface_data.m 2KB
ft_estimate_units.m 2KB
subsref.m 2KB
fixname.m 2KB
fixpos.m 2KB
共 216 条
- 1
- 2
- 3
资源评论
若明天不见
- 粉丝: 1w+
- 资源: 273
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 筷手引流工具.apk
- 论文(最终)_20240430235101.pdf
- 基于python编写的Keras深度学习框架开发,利用卷积神经网络CNN,快速识别图片并进行分类
- 最全空间计量实证方法(空间杜宾模型和检验以及结果解释文档).txt
- 5uonly.apk
- 蓝桥杯Python组的历年真题
- 2023-04-06-项目笔记 - 第一百十九阶段 - 4.4.2.117全局变量的作用域-117 -2024.04.30
- 2023-04-06-项目笔记 - 第一百十九阶段 - 4.4.2.117全局变量的作用域-117 -2024.04.30
- 前端开发技术实验报告:内含4四实验&实验报告
- Highlight Plus v20.0.1
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功