TenetoBIDS

class TenetoBIDS(bids_dir, selected_pipeline, bids_filter=None, bidsvalidator=False, update_pipeline=True, history=None, exist_ok=False, layout=None, nettsv='nn-t')[source]

Bases: object

Class for analysing data in BIDS.

TenetoBIDS allows for an analysis to be performed across a dataset. All different functions from Teneto can be applied to all files in a dataset organized in BIDS. Data should be first preprocessed (e.g. fMRIPrep).

Parameters:
  • bids_dir (str) – string to BIDS directory
  • selected_pipeline (str or dict) –

    the directory that is in the bids_dir/derivatives/<selected_pipeline>/. This fine will be used as the input to any teneto function (first argument). If multiple inputs are required for a function, then you can specify:

    {‘netin’: ‘tvc’, ‘communities’: ‘coms’}

    With this, the input for netin with be from bids_dir/derivatives/[teneto-]tvc/, and the input for communities will be from bids_dir/derivatives/[teneto-]coms/. The keys in this dictionary must match the names of the teneto funciton inputs.

  • bids_filter (dict) –
  • history (bool) –
  • update_pipeline (bool) – If true, the output_pipeline becomes the new selected_pipeline
  • exist_ok (bool) – If False, will raise an error if the output directory already exist_ok. If True, will not raise an error. This can lead to files being overwritten, if desc is not set.
  • nettsv (str can be nn-t or ijt.) – nn-t means networks are node-node x time. ijt means daframs are ijt columns.

Methods Summary

create_output_pipeline(runc_func, …[, …]) Creates the directories of the saved file.
get_aux_file(bidsfile[, filetype]) Tries to automatically get auxiliary data for input files, and loads it
get_run_options([for_selected]) Returns the different function names that can be called using TenetoBIDS.run()
get_selected_files([output]) Uses information in selected_pipeline and the bids layout and shows the files that will be processed when calling TenetoBIDS.run().
load_data([bids_filter]) Returns data, default is the input data.
load_events() Loads event data for selected files
load_file(bidsfile) Aux function to load the data and sidecar from a BIDSFile
run(run_func, input_params[, output_desc, …]) Runs a runction on the selected files.
troubleshoot(stepname, status) Prints ongoing info to assist with troubleshooting
update_bids_filter(filter_addons) Updates TenetoBIDS.bids_filter
update_bids_layout() Function that upddates to new bids l

Methods Documentation

create_output_pipeline(runc_func, output_pipeline_name, exist_ok=None)[source]

Creates the directories of the saved file.

Parameters:
  • output_pipeline (str) – name of output pipeline
  • exist_ok (bool) – If False, will raise error if pipeline already exist_ok. If True, will not raise an error. This can lead to files being overwritten, if desc is not set. If None, will use the exist_ok set during init.
Returns:

bids_dir/teneto-[output_pipeline]/

Return type:

Creates the output pipeline directory in

get_aux_file(bidsfile, filetype='confounds')[source]

Tries to automatically get auxiliary data for input files, and loads it

bidsfile : BIDSDataFile or BIDSImageFile
The BIDS file that the confound file is gong to be matched.
filetype : string
Can be confounds, events. Specified if you want to get the confound or events data.
get_run_options(for_selected=True)[source]

Returns the different function names that can be called using TenetoBIDS.run()

Parameters:for_selected (bool) – If True, only return run options for the selected files. If False, returns all options.
Returns:options – a list of options that can be run.
Return type:str
get_selected_files(output=None)[source]

Uses information in selected_pipeline and the bids layout and shows the files that will be processed when calling TenetoBIDS.run().

If you specify a particular output, it will tell you which files will get selected for that output

load_data(bids_filter=None)[source]

Returns data, default is the input data.

bids_filter : dict
default is None. If set, load data will load all files found by the bids_filter. Any preset BIDS filter is used as well, but will get overwritten by this input.
load_events()[source]

Loads event data for selected files

load_file(bidsfile)[source]

Aux function to load the data and sidecar from a BIDSFile

bidsfile : BIDSDataFile or BIDSImageFile
The BIDS file that the confound file is gong to be matched.
run(run_func, input_params, output_desc=None, output_pipeline_name=None, bids_filter=None, update_pipeline=True, exist_ok=None, troubleshoot=False)[source]

Runs a runction on the selected files.

Parameters:
  • run_func (str) – str should correspond to a teneto function. So to run the funciton teneto.timeseries.derive_temporalnetwork the input should be: ‘timeseries.derive_temporalnetwork’
  • input_params (dict) – keyword and value pairing of arguments for the function being run. The input data to each function will be located automatically. This input_params does not need to include the input network. For any other input that needs to be loaded loaded within the teneto_bidsstructure (communities, events, confounds), you can pass the value “bids” if they can be found within the current selected_pipeline. If they are found within a different selected_pipeline, type “bids_[selected_pipeline]”.
  • output_desc (str) – If none, no desc is used (removed any previous file) If ‘keep’, then desc is preserved. If any other str, desc is set to that string
  • output_pipeline_name (str) – If set, then the data is saved in teneto_[functionname]_[output_pipeline_name]. If run_func is teneto.timeseries.derive_temporalnetwork and output_pipeline_name is jackknife then then the pipeline the data is saved in is teneto-generatetemporalnetwork_jackknife
  • update_pipeline (bool) – If set to True (default), then the selected_pipeline updates to output of function
  • exist_ok (bool) – If set to True, then overwrites direcotry is possible.
  • troubleshoot (bool) – If True, prints out certain information during running. Useful to run if reporting a bug.
troubleshoot(stepname, status)[source]

Prints ongoing info to assist with troubleshooting

update_bids_filter(filter_addons)[source]

Updates TenetoBIDS.bids_filter

Parameters:filter_addons (dict) – dictionary that updates TenetoBIDS.bids_filter
update_bids_layout()[source]

Function that upddates to new bids l