Giter Club home page Giter Club logo

dfc's Introduction

Pypi Package

pydfc

An implementation of several well-known dynamic Functional Connectivity (dFC) assessment methods.

Simply install pydfc using the following steps:
  • conda create --name pydfc_env python=3.11
  • conda activate pydfc_env
  • pip install pydfc

The dFC_methods_demo.ipynb illustrates how to load data and apply each of the dFC methods implemented in the pydfc toolbox individually. The multi_analysis_demo.ipynb illustrates how to use the pydfc toolbox to apply multiple dFC methods at the same time on a dataset and compare their results.

For more details about the implemented methods and the comparison analysis see our paper.

  • Mohammad Torabi, Georgios D Mitsis, Jean-Baptiste Poline, On the variability of dynamic functional connectivity assessment methods, GigaScience, Volume 13, 2024, giae009, https://doi.org/10.1093/gigascience/giae009.

dfc's People

Contributors

mtorabi59 avatar remi-gau avatar effigies avatar dependabot[bot] avatar

Stargazers

Zijian Chen avatar Huijin Song avatar Bati Yilmaz avatar  avatar Isil Bilgin avatar Felipe Cybis Pereira avatar Will Decker avatar  avatar  avatar  avatar Roza Gunes Bayrak avatar

Watchers

James Cloos avatar  avatar

dfc's Issues

demo does not work

Had some issues when downloading the data:

Had to add double quotes around file names to make it run: probably because I am using zsh as my shell.

Note that this may make it hard for windows users to run the demo because curl has a different syntax on windows I think.

!curl --create-dirs "https://s3.amazonaws.com/openneuro.org/ds002785/derivatives/fmriprep/sub-0001/func/sub-0001_task-restingstate_acq-mb3_space-MNI152NLin2009cAsym_desc-preproc_bold.nii.gz?versionId=UfCs4xtwIEPDgmb32qFbtMokl_jxLUKr" -o "sample_data/sub-0001_task-restingstate_acq-mb3_space-MNI152NLin2009cAsym_desc-preproc_bold.nii.gz"
!curl --create-dirs "https://s3.amazonaws.com/openneuro.org/ds002785/derivatives/fmriprep/sub-0001/func/sub-0001_task-restingstate_acq-mb3_desc-confounds_regressors.tsv?versionId=biaIJGNQ22P1l1xEsajVzUW6cnu1_8lD" -o "sample_data/sub-0001_task-restingstate_acq-mb3_desc-confounds_regressors.tsv"

I am then getting an error at this step:

# load sub-0001 data from nifti file
BOLD = data_loader.nifti2timeseries(
            nifti_file='sample_data/sub-0001_task-restingstate_acq-mb3_space-MNI152NLin2009cAsym_desc-preproc_bold.nii.gz', 
            n_rois=100, Fs=1/0.75,
            subj_id='sub-0001',
            confound_strategy='no_motion', # no_motion, no_motion_no_gsr, or none
            standardize=False,
            TS_name=None,
            session=None,
        )

BOLD.visualize( start_time=0, end_time=1000, nodes_lst=range(10))
{
	"name": "IndexError",
	"message": "only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices",
	"stack": "---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
Cell In[6], line 2
      1 # load sub-0001 data from nifti file
----> 2 BOLD = data_loader.nifti2timeseries(
      3             nifti_file='sample_data/sub-0001_task-restingstate_acq-mb3_space-MNI152NLin2009cAsym_desc-preproc_bold.nii.gz', 
      4             n_rois=100, Fs=1/0.75,
      5             subj_id='sub-0001',
      6             confound_strategy='no_motion', # no_motion, no_motion_no_gsr, or none
      7             standardize=False,
      8             TS_name=None,
      9             session=None,
     10         )
     12 BOLD.visualize( start_time=0, end_time=1000, nodes_lst=range(10))

File ~/github/origami/dFC/pydfc/data_loader.py:243, in nifti2timeseries(nifti_file, n_rois, Fs, subj_id, confound_strategy, standardize, TS_name, session)
    225 def nifti2timeseries(
    226         nifti_file, 
    227         n_rois, Fs,
   (...)
    232         session=None,
    233     ):
    234     '''
    235     this function is only for single subject and single session data loading 
    236     it uses nilearn maskers to extract ROI signals from nifti files
   (...)
    241     {100, 200, 300, 400, 500, 600, 700, 800, 900, 1000}
    242     '''
--> 243     time_series, labels, locs = nifti2array(
    244         nifti_file=nifti_file, 
    245         confound_strategy=confound_strategy, 
    246         standardize=standardize,
    247         n_rois=n_rois
    248     )
    250     assert type(locs) is np.ndarray, 'locs must be a numpy array'
    251     assert type(labels) is list, 'labels must be a list'

File ~/github/origami/dFC/pydfc/data_loader.py:205, in nifti2array(nifti_file, confound_strategy, standardize, n_rois)
    199 elif confound_strategy=='no_motion':
    200     confounds_simple, sample_mask = load_confounds(
    201         nifti_file,
    202         strategy=[\"high_pass\", \"motion\", \"wm_csf\"],
    203         motion=\"basic\", wm_csf=\"basic\"
    204     )
--> 205     time_series = masker.fit_transform(
    206         nifti_file,
    207         confounds=confounds_simple,
    208         sample_mask=sample_mask
    209     )
    210 elif confound_strategy=='no_motion_no_gsr':
    211     confounds_simple, sample_mask = load_confounds(
    212         nifti_file,
    213         strategy=[\"high_pass\", \"motion\", \"wm_csf\", \"global_signal\"],
    214         motion=\"basic\", wm_csf=\"basic\", global_signal=\"basic\"
    215     )

File ~/miniconda3/lib/python3.11/site-packages/sklearn/utils/_set_output.py:140, in _wrap_method_output.<locals>.wrapped(self, X, *args, **kwargs)
    138 @wraps(f)
    139 def wrapped(self, X, *args, **kwargs):
--> 140     data_to_wrap = f(self, X, *args, **kwargs)
    141     if isinstance(data_to_wrap, tuple):
    142         # only wrap the first output for cross decomposition
    143         return (
    144             _wrap_data_with_container(method, data_to_wrap[0], X, self),
    145             *data_to_wrap[1:],
    146         )

File ~/github/nilearn/nilearn/nilearn/maskers/nifti_labels_masker.py:531, in NiftiLabelsMasker.fit_transform(self, imgs, confounds, sample_mask)
    500 def fit_transform(self, imgs, confounds=None, sample_mask=None):
    501     \"\"\"Prepare and perform signal extraction from regions.
    502 
    503     Parameters
   (...)
    529 
    530     \"\"\"
--> 531     return self.fit(imgs).transform(
    532         imgs, confounds=confounds, sample_mask=sample_mask
    533     )

File ~/miniconda3/lib/python3.11/site-packages/sklearn/utils/_set_output.py:140, in _wrap_method_output.<locals>.wrapped(self, X, *args, **kwargs)
    138 @wraps(f)
    139 def wrapped(self, X, *args, **kwargs):
--> 140     data_to_wrap = f(self, X, *args, **kwargs)
    141     if isinstance(data_to_wrap, tuple):
    142         # only wrap the first output for cross decomposition
    143         return (
    144             _wrap_data_with_container(method, data_to_wrap[0], X, self),
    145             *data_to_wrap[1:],
    146         )

File ~/github/nilearn/nilearn/nilearn/maskers/base_masker.py:267, in BaseMasker.transform(self, imgs, confounds, sample_mask)
    264     else:
    265         all_confounds.append(confounds)
--> 267 return self.transform_single_imgs(
    268     imgs, confounds=all_confounds, sample_mask=sample_mask
    269 )

File ~/github/nilearn/nilearn/nilearn/maskers/nifti_labels_masker.py:703, in NiftiLabelsMasker.transform_single_imgs(self, imgs, confounds, sample_mask)
    700     region_ids[i] = ids[i]
    702 if self.labels is not None:
--> 703     self.region_names_ = {
    704         key: self.labels[region_id]
    705         for key, region_id in region_ids.items()
    706         if region_id != self.background_label
    707     }
    708 else:
    709     self.region_names_ = None

File ~/github/nilearn/nilearn/nilearn/maskers/nifti_labels_masker.py:704, in <dictcomp>(.0)
    700     region_ids[i] = ids[i]
    702 if self.labels is not None:
    703     self.region_names_ = {
--> 704         key: self.labels[region_id]
    705         for key, region_id in region_ids.items()
    706         if region_id != self.background_label
    707     }
    708 else:
    709     self.region_names_ = None

IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices"
}

Add support for numpy array is input.

Hi,
given your provided code:

measure = SLIDING_WINDOW(**params_methods)
dFC = measure.estimate_dFC(time_series=BOLD)

It would seem easier if that function also works with a simple numpy array containing the channels and time series, without needing, for example, a subject list. This would also simplify the integration of a nilearn workflow.

Thanks and best wishes

git LFS quota

@mtorabi59

not sure what data you have put on git LFS but I think we should purge some of it because it will be a blocker for others

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.