dnnbrain.io.fileio module¶
- class dnnbrain.io.fileio.ActivationFile(fname)¶
Bases:
objecta class to read and write activation file
- read(dmask=None)¶
Read DNN activation
- Parameters
dmask (dict) – Dictionary of the DNN mask information
- Returns
activation – DNN activation
- Return type
dict
- write(activation)¶
Write DNN activation to a hdf5 file
- Parameters
activation (dict) – DNN activation
- class dnnbrain.io.fileio.MaskFile(fname)¶
Bases:
objecta class to read and write dnn mask file
- read()¶
Read DNN mask
- Returns
dmask – Dictionary of the DNN mask information
- Return type
OrderedDict
- write(dmask)¶
Generate .dmask.csv
- Parameters
dmask (dict) – Dictionary of the DNN mask information
- class dnnbrain.io.fileio.RdmFile(fname)¶
Bases:
objectA class to read/write representation distance matrices (RDMs) from/to .rdm.h5 file. For saving time and space, DNNBrain only hold on the upper triangle of each RDM. We can use np.tri(n_item, k=-1, dtype=np.bool).T to get the index array of the upper triangle. The index array can help us to restore RDM from the upper triangle whose shape is ((n_item^2-n_item)/2,).
- read()¶
Read RDMs from .rdm.h5 file
- Returns
rdm_type (str) – Choices=(bRDM, dRDM) bRDM: RDM for brain activation dRDM: RDM for DNN activation
rdm_dict (dict) – A dict containing the RDM information
RDM type
Keys
Values
bRDM
Labels of brain ROIs
Arrays with shape as ((n_item^2-n_item)/2,)
dRDM
Layer names
Arrays with shape as (n_iter, (n_item^2-n_item)/2)
- write(rdm_type, rdm_dict)¶
write RDMs to .rdm.h5 file
- Parameters
rdm_type (str) – Choices=(bRDM, dRDM) bRDM: RDM for brain activation dRDM: RDM for DNN activation
rdm_dict (dict) –
A dict containing the RDM information
RDM type
Keys
Values
bRDM
Labels of brain ROIs
Arrays with shape as ((n_item^2-n_item)/2,)
dRDM
Layer names
Arrays with shape as (n_iter, (n_item^2-n_item)/2)
- class dnnbrain.io.fileio.RoiFile(fname)¶
Bases:
objecta class to read and write roi file
- read(rois=None)¶
Read data of ROIs of the brain.
- Parameters
rois (str, list) – ROI names of interest
- Returns
rois (list) – ROI names which are corresponding to columns in data
data (array) – ROI data
- write(rois, data)¶
Write data of ROIs of the brain.
- Parameters
rois (str, list) – ROI names which are corresponding to columns in data
data (array) – ROI data
- class dnnbrain.io.fileio.StimulusFile(fname)¶
Bases:
objectA class to read and write stimulus file
- read()¶
- Returns
stimuli – Dictionary of the stimuli information
- Return type
OrderedDict
- write(type, path, data, **opt_meta)¶
- Parameters
type (str) – Stimulus type in (‘image’, ‘video’, ‘video_clip’)
path (str) –
Path_to_stimuli.
If type is ‘image’, the path is the parent directory of the images. If type is ‘video’, the path is the file name of the video. If type is ‘video_clip’, the path is the parent directory of the video clips.
data (dict) – Stimulus variable data
opt_meta (dict) – Some other optional meta data