NIPY logo

Site Navigation

NIPY Community

Table Of Contents

Next topic

neurospin.glm_files_layout.glm_tools

This Page

neurospin.glm_files_layout.cortical_glm

Module: neurospin.glm_files_layout.cortical_glm

eneral tools to analyse fMRI datasets (GLM fit) sampled on the surface.

This relies massively on glm_tools, and on the tio module to perform io on (AIMS .tex) textures. This should be replaced in a near future by pygifti modules.

Author : Bertrand Thirion, 2010

Functions

nipy.neurospin.glm_files_layout.cortical_glm.compute_contrasts(contrast_struct, misc, CompletePaths, glms=None, model='default', **kargs)

Contrast computation utility

Parameters :

contrast_struct, ConfigObj instance or string :

it yields the set of contrasts of the multi-session model or the path to a configobj that specifies the contarsts

misc: misc object instance, :

misc information on the datasets used here or path to a configobj file that yields the misc info

Complete_Paths: dictionary or string, :

yields all paths, indexed by contrasts, where outputs will be written if it is a string, all the paths are re-generated based on it as a output directory

glms, dictionary of nipy.neurospin.glm.glm.glm instances :

indexed by sessions, optional if it is not provided, a ‘glm_config’ instance should be provided in kargs

nipy.neurospin.glm_files_layout.cortical_glm.generate_all_brainvisa_paths(base_path, sessions, fmri_wc, model_id, misc_id='misc_info.con', paradigm_id='paradigm.csv', contrast_id='contrast.con', design_id='design_mat.csv', glm_dump='vba.npz', glm_config='vba_config.con')

This function returns a dictionary with all the paths of all the paths where something id read or written in a standard GLM. The hard-coded paths reflect brainvisa database conventions. Additionally, this creates the missing output directories.

Parameters :

base_path: string, :

path of the acquition (contains database, subject and acquitision ids)

sessions: list of strings :

list of all the session related to the acquisition

fmri_wc: string, :

wildcard for fMRI data files, assumed to be the same for all sessions

model_id: string, :

identifier of the model

misc_id: string, optional :

identifier of the ‘misc file’ that contains meta-information

paradigm_id: string, optional :

identifier of the paradigm file (should be a .csv file)

contrast_id: string, optional :

id of the contrast file

design_id: string, optional :

id of the design matrices file

glm_dump: string, optional, :

id of the glm dump file (should be .npz file)

glm_config: string, optional, :

id of the glm config file (should disappear in the near future)

Returns :

paths, dictionary :

containing all the paths that are required to perform a glm with brainvisa

nipy.neurospin.glm_files_layout.cortical_glm.generate_brainvisa_ouput_paths(output_dir_path, contrasts, side, z_file=True, stat_file=True, con_file=True, res_file=True)

This function generate standard output paths for all the contrasts and arranges them in a dictionary

Parameters :

output_dir_path: string, :

path of the output dir

contrasts: ConfigObj instance, :

contrast_structure

side: string, :

‘left’ or ‘right’ (as these are yusually in separate files) this will be a prefix to all paths

z_file: bool, optional :

whether the z_file should be written or not

stat_file: bool, optional :

whether the stat file (t or F) should be written or not

con_file: bool, optional, :

whether the contrast file should be written or not

res_file: bool, optional :

whether the residual variance file should be written or not

Returns :

path, a dictiorany with all paths :

nipy.neurospin.glm_files_layout.cortical_glm.glm_fit(fMRI_path, DesignMatrix=None, output_glm=None, outputCon=None, fit='Kalman_AR1', design_matrix_path=None, data_scaling=True)

Call the GLM Fit function with apropriate arguments

Parameters :

fMRI_path, string or list of strings, :

path of the fMRI data file(s)

design_matrix, DesignMatrix instance, optional :

design matrix of the model

output_glm, string, optional :

path of the output glm .npz dump

outputCon, string,optional :

path of the output configobj contrast object

fit= ‘Kalman_AR1’, string to be chosen among :

“Kalman_AR1”, “Ordinary Least Squares”, “Kalman” that represents both the model and the fit method

design_marix_path: string, :

path of the design matrix .csv file

data_scaling: bool, Optional :

scaling of the data to mean value

Returns :

glm, a nipy.neurospin.glm.glm instance representing the GLM :

nipy.neurospin.glm_files_layout.cortical_glm.load_texture(path)

Return an array from texture data

Parameters :

path string or list of strings :

path of the texture files

Returns :

data array of shape (nnode) or (nnode, len(path)) :

the orresponding data

nipy.neurospin.glm_files_layout.cortical_glm.save_all_textures(contrast, dim, kargs)

idem savel_all, but the names are now all included in kargs

nipy.neurospin.glm_files_layout.cortical_glm.save_texture(path, data)

volume saving utility for textures

Parameters :

path, string, output image path :

data, array of shape (nnode) :

data to be put in the volume