pyhrf.core module¶
-
class
pyhrf.core.
AttrClass
(**kwargs)¶ Bases:
object
Base class to display attributes.
-
class
pyhrf.core.
Condition
(**kwargs)¶ Bases:
pyhrf.core.AttrClass
Represents an activation condition
-
class
pyhrf.core.
FMRISessionSimulationData
(onsets=OrderedDict([('audio', array([ 15., 20.7, 29.7, 35.4, 44.7, 48., 83.4, 89.7, 108., 119.4, 135., 137.7, 146.7, 173.7, 191.7, 236.7, 251.7, 284.4, 293.4, 296.7])), ('video', array([ 0., 2.4, 8.7, 33., 39., 41.7, 56.4, 59.7, 75., 96., 122.7, 125.4, 131.4, 140.4, 149.4, 153., 156., 159., 164.4, 167.7, 176.7, 188.4, 195., 198., 201., 203.7, 207., 210., 218.7, 221.4, 224.7, 234., 246., 248.4, 260.4, 264., 266.7, 269.7, 278.4, 288. ]))]), durations=OrderedDict([('audio', array([], dtype=float64)), ('video', array([], dtype=float64))]), simulation_file='/home/tperret/code/pyhrf/python/pyhrf/datafiles/simu.pck')¶ Bases:
pyhrf.xmlio.Initable
-
to_dict
()¶
-
-
class
pyhrf.core.
FMRISessionSurfacicData
(onsets=OrderedDict([('audio', array([ 15., 20.7, 29.7, 35.4, 44.7, 48., 83.4, 89.7, 108., 119.4, 135., 137.7, 146.7, 173.7, 191.7, 236.7, 251.7, 284.4, 293.4, 296.7])), ('video', array([ 0., 2.4, 8.7, 33., 39., 41.7, 56.4, 59.7, 75., 96., 122.7, 125.4, 131.4, 140.4, 149.4, 153., 156., 159., 164.4, 167.7, 176.7, 188.4, 195., 198., 201., 203.7, 207., 210., 218.7, 221.4, 224.7, 234., 246., 248.4, 260.4, 264., 266.7, 269.7, 278.4, 288. ]))]), durations=OrderedDict([('audio', array([], dtype=float64)), ('video', array([], dtype=float64))]), bold_file='/home/tperret/code/pyhrf/python/pyhrf/datafiles/real_data_surf_tiny_bold.gii')¶ Bases:
pyhrf.xmlio.Initable
-
to_dict
()¶
-
-
class
pyhrf.core.
FMRISessionVolumicData
(onsets=OrderedDict([('audio', array([ 15., 20.7, 29.7, 35.4, 44.7, 48., 83.4, 89.7, 108., 119.4, 135., 137.7, 146.7, 173.7, 191.7, 236.7, 251.7, 284.4, 293.4, 296.7])), ('video', array([ 0., 2.4, 8.7, 33., 39., 41.7, 56.4, 59.7, 75., 96., 122.7, 125.4, 131.4, 140.4, 149.4, 153., 156., 159., 164.4, 167.7, 176.7, 188.4, 195., 198., 201., 203.7, 207., 210., 218.7, 221.4, 224.7, 234., 246., 248.4, 260.4, 264., 266.7, 269.7, 278.4, 288. ]))]), durations=OrderedDict([('audio', array([], dtype=float64)), ('video', array([], dtype=float64))]), bold_file='/home/tperret/code/pyhrf/python/pyhrf/datafiles/subj0_bold_session0.nii.gz')¶ Bases:
pyhrf.xmlio.Initable
-
parametersComments
= {'onsets': 'Onsets of experimental simtuli in seconds. \nDictionnary mapping stimulus name to the actual list of onsets.', 'durations': 'Durations of experimental simtuli in seconds.\nIt has to consistent with the definition of onsets', 'bold_file': 'Data file containing the 3D+time BOLD signal (nifti format)'}¶
-
to_dict
()¶
-
-
class
pyhrf.core.
FmriData
(onsets, bold, tr, sessionsScans, roiMask, graphs=None, stimDurations=None, meta_obj=None, simulation=None, backgroundLabel=0, data_files=None, data_type=None, edge_lengths=None, mask_loaded_from_file=False, extra_data=None)¶ Bases:
pyhrf.xmlio.Initable
-
onsets -- a dictionary mapping a stimulus name to a list of session onsets.
Each item of this list is a 1D numpy float array of onsets for a given session.
-
stimDurations -- same as 'onsets' but stores durations of stimuli
-
roiMask -- numpy int array of roi labels
0 stands for the background – shape depends on the data form (3D volumic or 1D surfacic)
-
bold -- either a 4D numpy float array with axes [sag,cor,ax,scan] and then
spatial axes must have the same shape as roiMask, Or a 2D numpy float array with axes [scan, position] and position axis must have the same length as the number of positions within roiMask (without background). Sessions are stacked in the scan axis
-
sessionsScans -- a list of session indexes along scan axis.
-
tr -- Time of repetition of the BOLD signal
-
simulation -- if not None then it should be a list of simulation instance.
-
meta_obj -- extra information associated to data
-
average
(flag=True)¶
-
build_graphs
(force=False)¶
-
compute_average
()¶
-
discard_rois
(roi_ids)¶
-
discard_small_rois
(min_size)¶
-
classmethod
from_simu_ui
(sessions_data=None)¶
-
classmethod
from_simulation_dict
(simulation, mask=None)¶
-
classmethod
from_surf_files
(paradigm_csv_file='/home/tperret/code/pyhrf/python/pyhrf/datafiles/paradigm_loc_av.csv', bold_files=None, tr=2.4, mesh_file='/home/tperret/code/pyhrf/python/pyhrf/datafiles/real_data_surf_tiny_mesh.gii', mask_file=None)¶ Return FmriData representation from surf files
-
classmethod
from_surf_ui
(sessions_data=None, tr=2.4, mask_file='/home/tperret/code/pyhrf/python/pyhrf/datafiles/real_data_surf_tiny_parcellation.gii', mesh_file='/home/tperret/code/pyhrf/python/pyhrf/datafiles/real_data_surf_tiny_mesh.gii')¶ Convenient creation function intended to be used for XML I/O. ‘session_data’ is a list of FMRISessionVolumicData objects. ‘tr’ is the time of repetition. ‘mask_file’ is a path to a functional mask file.
- This represents the following hierarchy:
- FMRIData:
- list of session data:
- [ * data for session 1:
- onsets for session 1,
- durations for session 1,
- fmri data file for session 1 (gii)
- data for session 2:
- onsets for session 2,
- durations for session 2,
- fmri data file for session 2 (gii)
],
time of repetition
mask file
mesh file
-
from_vol_files
¶
-
from_vol_files_rel
¶
-
from_vol_ui
¶
-
getSummary
(long=False)¶
-
get_condition_names
()¶
-
get_data_files
()¶
-
get_extra_data
(label, default)¶
-
get_graph
()¶
-
get_joined_durations
()¶
-
get_joined_onsets
()¶
-
get_nb_rois
()¶ Return the number of parcels (background id is discarded)
-
get_nb_vox_in_mask
()¶
-
get_roi_id
()¶ In case of FMRI data containing only one ROI, return the id of this ROI. If data contains several ROIs then raise an exception
-
get_roi_mask
()¶
-
keep_only_rois
(roiIds)¶
-
parametersComments
= {'mask_file': 'Input n-ary mask file (= parcellation). Only positive integers are allowed. \nAll zeros are treated as background positions.', 'tr': 'repetition time in seconds', 'sessions_data': 'List of data definition for all sessions'}¶
-
parametersToShow
= ['tr', 'sessions_data', 'mask_file']¶
-
roiMask
¶
-
roi_split
(mask=None)¶
-
save
(output_dir)¶ Save paradigm to output_dir/paradigm.csv, BOLD to output_dir/bold.nii, mask to output_dir/mask.nii #TODO: handle multi-session
Return: tuple of file names in this order: (paradigm, bold, mask)
-
set_extra_data
(label, value)¶
-
store_mask_sparse
(roiMask)¶
-
-
class
pyhrf.core.
FmriGroupData
(list_subjects)¶ Bases:
pyhrf.xmlio.Initable
Used for group level hemodynamic analysis Encapsulates FmriData objects for all subjects All subjects must habe the same number of ROIs
- Inputs:
- list_subjects: contains list of FmriData object for each subject
-
build_graphs
(force=False)¶
-
getSummary
(long=False)¶
-
get_roi_id
()¶
-
roi_split
()¶ Retrieve a list of FmriGroupData object, each containing the data for all subject, in one ROI
-
class
pyhrf.core.
Object
¶ Bases:
object
-
pyhrf.core.
get_data_file_name
(filename)¶ Return the path of a given filename.
-
pyhrf.core.
get_roi_simulation
(simu_sessions, mask, roi_id)¶ Extract the ROI from the given simulation dict. :param - simu: dictionnary of simulated quantities :type - simu: dict :param - mask: binary mask defining the spatial extent of the ROI :type - mask: np.ndarray :param - roi_id: the id of the roi to extract :type - roi_id: int
Returns: dict of roi-specific simulation items
-
pyhrf.core.
get_src_doc_path
()¶ Return the documentation path of pyhrf.
-
pyhrf.core.
get_src_path
()¶ Return the source path of pyhrf.
-
pyhrf.core.
get_tmp_path
(tag='pyhrf_')¶ Return a temporary path.
-
pyhrf.core.
list_data_file_names
()¶ List all the data filenames.
-
pyhrf.core.
load_surf_bold_mask
(bold_files, mesh_file, mask_file=None)¶
-
pyhrf.core.
load_vol_bold_and_mask
(bold_files, mask_file)¶
-
pyhrf.core.
merge_fmri_sessions
(fmri_data_sets)¶ fmri_data_sets: list of FmriData objects. Each FmriData object is assumed to contain only one session
-
pyhrf.core.
merge_fmri_subjects
(fmri_data_sets, roiMask, backgroundLabel=0)¶ fmri_data_sets: list of FmriData objects, for different subjects. In case of multisession data, merging of fmri data over sessions must be done for each subject before using this function. roiMask: multi_subject parcellation (nparray)