cifti-matlab开源项目

我要开发同款
匿名用户2021年11月23日
62阅读
所属分类、应用工具、科研计算工具
授权协议View license

作品详情

MATLABcodeforreadingandwritingCIFTIfiles,v2

ThislibraryiscompatiblewiththeCIFTI-2format,withoutexternallyinstalleddependencies(exceptthatCIFTI-1filesrequirewb_commandforconversion),returningastructurethatexposestheinformationcontainedintheCIFTI-2XMLwithminimaltranslation,aswellasthedatamatrixwithnoaddedpadding.Thecifti_readfunctionistheintendedstartingpoint,ciftiopenandsimilararecompatibilitywrapperssothatthelibrarycanbeusedinoldercode.

Additionally,thelibraryprovidesnumeroushelperfunctionstomakemanycommonoperations(suchasextractingthedataforonestructure)intoasinglelineofintuitivecode.

ThepreviouscodethatwasderivedfromFieldTripisinthe"ft_cifti"folder.

Theciftistructurereturnedbythislibraryuses0-basedindicesforvertexandvoxelindices,1-basedforciftiindices,andthehelperfunctionsreturn1-basedindicesforeverything.

Usage

Allexposedfunctionshaveusageinformationavailablethroughthehelpcommand:

>>helpcifti_readfunctionoutstruct=cifti_read(filename,...)Readaciftifile....

Thesimplestpracticalusageistoloadaciftifilewithcifti_read,takeitsdatafromthe.cdatafield,modifyit,storeitbackintothe.cdatafield,andwriteitbackouttoanewfilewithcifti_write:

mycifti=cifti_read('something.dscalar.nii');mycifti.cdata=sqrt(mycifti.cdata);cifti_write(mycifti,'sqrt.dscalar.nii');

Theciftiopen,ciftisave,andciftisaveresetfunctionsprovidebackwardcompatibilitywithapreviousciftilibrary(optionIIofHCPFAQ2),andyoucanalsousethisciftisaveresetfunctionevenifyouusecifti_read.Analternativewaytodotheequivalentofciftisaveresetistousethecifti_write_from_templatehelperfunction(whichalsohasoptionstosetthenamesofthemapsfordscalar,andsimilarforotherciftifiletypes):

mycifti=cifti_read('something.dscalar.nii');cifti_write_from_template(mycifti,mycifti.cdata(:,1),'firstmap.dscalar.nii','namelist',{'map#1'});%ciftisaveresetequivalent(keeping'mycifti'unmodified):mycifti=cifti_read('something.dscalar.nii');newcifti=mycifti;newcifti.cdata=mycifti.cdata(:,1);ciftisavereset(newcifti,'firstmap.dscalar.nii');clearnewcifti;

Thecifti_struct_create_from_templatefunctioncancreateaciftistructwithoutwritingittoafile,withthesameoptionsascifti_write_from_templatetocontroltheotherdiminfo.Thecifti_write...orcifti_struct...functionsshouldhandlemostcasesofworkingwithcommonciftifiles,includingextractingthedataforonecorticalsurface,doingsomecomputationonit,andreplacingthesurfacedatawiththenewvalues:

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');...

Thedensepartofsomefunctionnamesreferstoonlybeingapplicableto"dense"filesordiminfo(inciftixmlterms,a"brainmodels"mapping),suchasdtseries,dscalar,dlabel,ordconn.Therearemoredensehelpersmainlybecausethereisamorecommonneedtomakeuseoftheinformationinadensediminfothanmostotherdiminfotypes.

Thecifti_diminfo_*helpersarelower-levelandrequiremoreunderstandingofthedetailsoftheciftiformat,andoftenrequirewritingmorecodetousethem,soyoushouldgenerallylookatthecifti_write...andcifti_struct...functionsfirst.

FunctionreferenceMainfunctionsread/writeandcompatibilityoutstruct=cifti_read(filename,...)cifti_write(cifti,filename,...)cifti=ciftiopen(filename,...)%note:these3donotuseoptionpairs,ciftisave(cifti,filename,...)%thevararginhereistomakepassing'wb_command'optionalciftisavereset(cifti,filename,...)structcreatehelpersandwriteconveniencefunctionscifti=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,...)densestructextract/replacehelpers[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)%returnsthenamesofstructuresthatexistinthisdiminfooutstring=cifti_metadata_get(metadata,key)%returnsemptystringfornonexistentkeymetadata=cifti_metadata_remove(metadata,key)%returnsunmodifiedmetadatastructfornonexistentkeymetadata=cifti_metadata_set(metadata,key,value)%overwriteskeyifitexistsSpecialusageadvanceddiminfohelpersoutinfo=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])advancedmiscindices=cifti_vox2ind(dims,voxlist1)%helpertoactlikesub2indforvoxelijklists
声明:本文仅代表作者观点,不代表本站立场。如果侵犯到您的合法权益,请联系我们删除侵权资源!如果遇到资源链接失效,请您通过评论或工单的方式通知管理员。未经允许,不得转载,本站所有资源文章禁止商业使用运营!
下载安装【程序员客栈】APP
实时对接需求、及时收发消息、丰富的开放项目需求、随时随地查看项目状态

评论