alignment - Linear and non-linear analysis methods¶
-
neural.alignment.affine_align(dset_from, dset_to, skull_strip=True, mask=None, suffix='_aff', prefix=None, cost=None, epi=False, resample='wsinc5', grid_size=None, opts=[])[source]¶ interface to 3dAllineate to align anatomies and EPIs
-
neural.alignment.affine_apply(dset_from, affine_1D, master, affine_suffix='_aff', interp='NN', inverse=False, prefix=None)[source]¶ apply the 1D file from a previously aligned dataset Applies the matrix in
affine_1Dtodset_fromand makes the final grid look like the datasetmasterusing the interpolation methodinterp. Ifinverseis True, will apply the inverse ofaffine_1Dinstead
-
neural.alignment.align_epi(anatomy, epis, suffix='_al', base=3, skull_strip=True)[source]¶ [[currently in progress]]: a simple replacement for the
align_epi_anat.pyscript, because I’ve found it to be unreliable, in my usage
-
neural.alignment.align_epi_anat(anatomy, epi_dsets, skull_strip_anat=True)[source]¶ aligns epis to anatomy using
align_epi_anat.pyscriptEpi_dsets: can be either a string or list of strings of the epi child datasets Skull_strip_anat: if True,anatomywill be skull-stripped using the default methodThe default output suffix is “_al”
-
neural.alignment.convert_coord(coord_from, matrix_file, base_to_aligned=True)[source]¶ Takes an XYZ array (in DICOM coordinates) and uses the matrix file produced by 3dAllineate to transform it. By default, the 3dAllineate matrix transforms from base to aligned space; to get the inverse transform set
base_to_alignedtoFalse
-
neural.alignment.motion_from_params(param_file, motion_file, individual=True, rms=True)[source]¶ calculate a motion regressor from the params file given by 3dAllineate
Basically just calculates the rms change in the translation and rotation components. Returns the 6 motion vector (if
individualisTrue) and the RMS difference (ifrmsisTrue).
-
neural.alignment.qwarp_align(dset_from, dset_to, skull_strip=True, mask=None, affine_suffix='_aff', suffix='_qwarp', prefix=None)[source]¶ aligns
dset_fromtodset_tousing 3dQwarpWill run
3dSkullStrip(unlessskull_stripisFalse),3dUnifize,3dAllineate, and then3dQwarp. This method will add suffixes to the input dataset for the intermediate files (e.g.,_ss,_u). If those files already exist, it will assume they were intelligently named, and use them as isSkull_strip: If True/False, turns skull-stripping of both datasets on/off. If a string matching dset_fromordset_to, will only skull-strip the given datasetMask: Applies the given mask to the alignment. Because of the nature of the alignment algorithms, the mask is always applied to the dset_to. If this isn’t what you want, you need to reverse the transform and re-apply it (e.g., usingqwarp_invert()andqwarp_apply()). If thedset_todataset is skull-stripped, the mask will also be resampled to match thedset_togrid.Affine_suffix: Suffix applied to dset_fromto name the new dataset, as well as the.1Dfile.Suffix: Suffix applied to the final dset_fromdataset. An additional file with the additional suffix_WARPwill be created containing the parameters (e.g., with the default_qwarpsuffix, the parameters will be in a file with the suffix_qwarp_WARP)Prefix: Alternatively to suffix, explicitly give the full output filenameThe output affine dataset and 1D, as well as the output of qwarp are named by adding the given suffixes (
affine_suffixandqwarp_suffix) to thedset_fromfileIf
skull_stripis a string instead ofTrue/False, it will only skull strip the given dataset instead of both of them# TODO: currently does not work with +tlrc datasets because the filenames get mangled
-
neural.alignment.qwarp_apply(dset_from, dset_warp, affine=None, warp_suffix='_warp', master='WARP', interp=None, prefix=None)[source]¶ applies the transform from a previous qwarp
Uses the warp parameters from the dataset listed in
dset_warp(usually the dataset name ends in_WARP) to the datasetdset_from. If a.1Dfile is given in theaffineparameter, it will be applied simultaneously with the qwarp.If the parameter
interpis given, will use as interpolation method, otherwise it will just use the default (currently wsinc5)Output dataset with have the
warp_suffixsuffix added to its name
-
neural.alignment.qwarp_epi(dset, align_subbrick=5, suffix='_qwal', prefix=None)[source]¶ aligns an EPI time-series using 3dQwarp
Very expensive and not efficient at all, but it can produce pretty impressive alignment for EPI time-series with significant distortions due to motion
-
neural.alignment.qwarp_invert(warp_param_dset, output_dset, affine_1Dfile=None)[source]¶ inverts a qwarp (defined in
warp_param_dset) (and concatenates affine matrixaffine_1Dfileif given) outputs the inverted warp + affine tooutput_dset
-
neural.alignment.skullstrip_template(dset, template, prefix=None, suffix=None, dilate=0)[source]¶ Takes the raw anatomy
dset, aligns it to a template brain, and applies a templated skullstrip. Should produce fairly reliable skullstrips as long as there is a decent amount of normal brain and the overall shape of the brain is normal-ish
-
neural.alignment.volreg(dset, suffix='_volreg', base=3, tshift=3, dfile_suffix='_volreg.1D')[source]¶ simple interface to 3dvolreg
Suffix: suffix to add to dsetfor volreg’ed fileBase: either a number or dset[#]of the base image to register toTshift: if a number, then tshift ignoring that many images, if Nonethen don’t tshiftDfile_suffix: suffix to add to dsetto save the motion parameters to