cifti-matlab开源项目

我要开发同款
匿名用户2021年11月23日
139阅读

技术信息

开源地址
https://github.com/didi/di18n
授权协议
View license

作品详情

MATLABcodeforreadigadwritigCIFTIfiles,v2

ThislibraryiscompatiblewiththeCIFTI-2format,withoutexterallyistalleddepedecies(exceptthatCIFTI-1filesrequirewb_commadforcoversio),returigastructurethatexposestheiformatiocotaieditheCIFTI-2XMLwithmiimaltraslatio,aswellasthedatamatrixwithoaddedpaddig.Thecifti_readfuctioistheitededstartigpoit,ciftiopeadsimilararecompatibilitywrapperssothatthelibrarycabeusedioldercode.

Additioally,thelibraryprovidesumeroushelperfuctiostomakemaycommooperatios(suchasextractigthedataforoestructure)itoasiglelieofituitivecode.

ThepreviouscodethatwasderivedfromFieldTripisithe"ft_cifti"folder.

Theciftistructurereturedbythislibraryuses0-basedidicesforvertexadvoxelidices,1-basedforciftiidices,adthehelperfuctiosretur1-basedidicesforeverythig.

Usage

Allexposedfuctioshaveusageiformatioavailablethroughthehelpcommad:

>>helpcifti_readfuctiooutstruct=cifti_read(fileame,...)Readaciftifile....

Thesimplestpracticalusageistoloadaciftifilewithcifti_read,takeitsdatafromthe.cdatafield,modifyit,storeitbackitothe.cdatafield,adwriteitbackouttoaewfilewithcifti_write:

mycifti=cifti_read('somethig.dscalar.ii');mycifti.cdata=sqrt(mycifti.cdata);cifti_write(mycifti,'sqrt.dscalar.ii');

Theciftiope,ciftisave,adciftisaveresetfuctiosprovidebackwardcompatibilitywithapreviousciftilibrary(optioIIofHCPFAQ2),adyoucaalsousethisciftisaveresetfuctioeveifyouusecifti_read.Aalterativewaytodotheequivaletofciftisaveresetistousethecifti_write_from_templatehelperfuctio(whichalsohasoptiostosettheamesofthemapsfordscalar,adsimilarforotherciftifiletypes):

mycifti=cifti_read('somethig.dscalar.ii');cifti_write_from_template(mycifti,mycifti.cdata(:,1),'firstmap.dscalar.ii','amelist',{'map#1'});%ciftisaveresetequivalet(keepig'mycifti'umodified):mycifti=cifti_read('somethig.dscalar.ii');ewcifti=mycifti;ewcifti.cdata=mycifti.cdata(:,1);ciftisavereset(ewcifti,'firstmap.dscalar.ii');clearewcifti;

Thecifti_struct_create_from_templatefuctiocacreateaciftistructwithoutwritigittoafile,withthesameoptiosascifti_write_from_templatetocotroltheotherdimifo.Thecifti_write...orcifti_struct...fuctiosshouldhadlemostcasesofworkigwithcommociftifiles,icludigextractigthedataforoecorticalsurface,doigsomecomputatiooit,adreplacigthesurfacedatawiththeewvalues:

mycifti=cifti_read('somethig.dscalar.ii');leftdata=cifti_struct_dese_extract_surface_data(mycifti,'CORTEX_LEFT');ewleftdata=1-leftdata;ewcifti=cifti_struct_dese_replace_surface_data(mycifti,ewleftdata,'CORTEX_LEFT');...

Thedesepartofsomefuctioamesreferstoolybeigapplicableto"dese"filesordimifo(iciftixmlterms,a"braimodels"mappig),suchasdtseries,dscalar,dlabel,ordco.Therearemoredesehelpersmailybecausethereisamorecommoeedtomakeuseoftheiformatioiadesedimifothamostotherdimifotypes.

Thecifti_dimifo_*helpersarelower-leveladrequiremoreuderstadigofthedetailsoftheciftiformat,adofterequirewritigmorecodetousethem,soyoushouldgeerallylookatthecifti_write...adcifti_struct...fuctiosfirst.

FuctiorefereceMaifuctiosread/writeadcompatibilityoutstruct=cifti_read(fileame,...)cifti_write(cifti,fileame,...)cifti=ciftiope(fileame,...)%ote:these3dootuseoptiopairs,ciftisave(cifti,fileame,...)%thevarargihereistomakepassig'wb_commad'optioalciftisavereset(cifti,fileame,...)structcreatehelpersadwritecoveiecefuctioscifti=cifti_struct_create_from_template(ciftitemplate,data,type,...)cifti_write_from_template(ciftitemplate,data,fileame,...)cifti=cifti_struct_create_sdseries(data,...)cifti_write_sdseries(data,fileame,...)desestructextract/replacehelpers[outdata,outroi]=cifti_struct_dese_extract_surface_data(cifti,structure[,dimesio])cifti=cifti_struct_dese_replace_surface_data(cifti,data,structure[,dimesio])[outdata,outsform1,outroi]=cifti_struct_dese_extract_volume_all_data(cifti[,cropped,dimesio])cifti=cifti_struct_dese_replace_volume_all_data(cifti,data[,cropped,dimesio])[outdata,outsform1,outroi]=cifti_struct_dese_extract_volume_structure_data(cifti,structure[,cropped,dimesio])cifti=cifti_struct_dese_replace_volume_structure_data(cifti,data,structure[,cropped,dimesio])misc[surflist,vollist]=cifti_dimifo_dese_get_structures(dimifo)%returstheamesofstructuresthatexistithisdimifooutstrig=cifti_metadata_get(metadata,key)%retursemptystrigforoexistetkeymetadata=cifti_metadata_remove(metadata,key)%retursumodifiedmetadatastructforoexistetkeymetadata=cifti_metadata_set(metadata,key,value)%overwriteskeyifitexistsSpecialusageadvaceddimifohelpersoutifo=cifti_dimifo_dese_get_surface_ifo(dimifo,structure)outifo=cifti_dimifo_dese_get_volume_all_ifo(dimifo[,cropped])outifo=cifti_dimifo_dese_get_volume_structure_ifo(dimifo,structure[,cropped])outmap=cifti_dimifo_make_scalars(ummaps[,amelist,metadatalist])outmap=cifti_dimifo_make_series(ummaps[,start,step,uit])advacedmiscidices=cifti_vox2id(dims,voxlist1)%helpertoactlikesub2idforvoxelijklists

功能介绍

MATLAB code for reading and writing CIFTI files, v2 This library is compatible with the CIFTI-2 f...

声明:本文仅代表作者观点,不代表本站立场。如果侵犯到您的合法权益,请联系我们删除侵权资源!如果遇到资源链接失效,请您通过评论或工单的方式通知管理员。未经允许,不得转载,本站所有资源文章禁止商业使用运营!
下载安装【程序员客栈】APP
实时对接需求、及时收发消息、丰富的开放项目需求、随时随地查看项目状态

评论