dsets - Simple manipulation of datasets

methods to do simple manipulations of datasets

class neural.dsets.DsetInfo[source]

Container for dset meta-data

All lists are returned in RAI order (i.e., a list of 3 numbers refers to the R-L axis, A-P axis, then I-S axis)

neural.dsets.afni_copy(filename)[source]

creates a +orig copy of the given dataset and returns the filename as a string

neural.dsets.auto_polort(dset)[source]

a copy of 3dDeconvolve’s -polort A option

neural.dsets.bounding_box(dset)[source]

return the coordinates (in RAI) of the corners of a box enclosing the data in dset

neural.dsets.dset_copy(dset, to_dir)[source]

robust way to copy a dataset (including AFNI briks)

neural.dsets.dset_grids_equal(dsets)[source]

Tests if each dataset in the list dsets has the same number of voxels and voxel-widths

neural.dsets.dset_info(dset)[source]

returns a DsetInfo object containing the meta-data from dset

neural.dsets.ijk_to_xyz(dset, ijk)[source]

convert the dset indices ijk to RAI coordinates xyz

neural.dsets.is_afni(filename)[source]

return True/False if this looks like an AFNI dset

neural.dsets.is_dset(filename)[source]

just checks if the filename has the format of an fMRI dataset

neural.dsets.is_nifti(filename)[source]

return True/False if this looks like a NIFTI dset

neural.dsets.nifti_copy(filename, prefix=None, gzip=True)[source]

creates a .nii copy of the given dataset and returns the filename as a string

neural.dsets.prefix(filename)[source]

strips common fMRI dataset suffixes from filenames

neural.dsets.resample_dset(dset, template, prefix=None, resam='NN')[source]

Resamples dset to the grid of template using resampling mode resam. Default prefix is to suffix _resam at the end of dset

Available resampling modes:
NN:Nearest Neighbor
Li:Linear
Cu:Cubic
Bk:Blocky
neural.dsets.strip_subbrick(filename)[source]

returns the filename without any [] subbrick modifiers

neural.dsets.subbrick(dset, label, coef=False, tstat=False, fstat=False, rstat=False, number_only=False)[source]

returns a string referencing the given subbrick within a dset

This method reads the header of the dataset dset, finds the subbrick whose label matches label and returns a string of type dataset[X], which can be used by most AFNI programs to refer to a subbrick within a file

The options coef, tstat, fstat, and rstat will add the suffix that is appended to the label by 3dDeconvolve

Coef:“#0_Coef”
Tstat:“#0_Tstat”
Fstat:“_Fstat”
Rstat:“_R^2”

if number_only is set to True, will only return the subbrick number instead of a string

neural.dsets.suffix(filename, suffix)[source]

returns a filenames with suffix inserted before the dataset suffix

class neural.dsets.temp_afni_copy(in_dset, out_dsets=None)[source]

used within a with block, will create a temporary +orig copy of dataset

When invoked in a with block, will make a +orig copy of the given dataset and return the filename as a string.

On exiting the block, it will delete the +orig copy. If out_dsets is a string or list of strings, it will try to make nifti copies of all datasets listed and then delete the original version if successful. AFNI datasets should be specified with the +view.

Example usage::
with temp_afni_copy(‘dataset.nii.gz’) as dset_afni:
do_something_with_a_dset(dset_afni)
with temp_afni_copy(‘dataset.nii.gz’,’output_dataset+orig’) as dset_afni:
do_something_with_a_dset(dset_afni,output=’output_dataset’)
neural.dsets.value_at_coord(dset, coords)[source]

returns value at specified coordinate in dset