Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated main.py #11

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
import numpy as np
from sklearn import covariance

from nilearn import input_data, datasets
from nilearn.input_data import NiftiLabelsMasker
from nilearn.datasets import fetch_atlas_basc_multiscale_2015

###############################################################################
# Functions used to build the container
Expand All @@ -18,7 +19,7 @@
def copy_atlas():
if not os.path.exists(ATLAS_DIR):
os.makedirs(ATLAS_DIR)
atlas_filename = datasets.fetch_atlas_basc_multiscale_2015().scale122
atlas_filename = fetch_atlas_basc_multiscale_2015().scale122
shutil.copy(atlas_filename, os.path.join(ATLAS_DIR, ATLAS_FILENAME))


Expand Down Expand Up @@ -50,19 +51,20 @@ def participant_level(args, subjects_to_analyze):
# Retrieve the atlas
atlas_filename = os.path.join(os.path.dirname(__file__),
ATLAS_DIR, ATLAS_FILENAME)
# build masker
masker = NiftiLabelsMasker(
labels_img=atlas_filename,
standardize=True,
detrend=True,
verbose=3)

# find all RS scans and extract time-series on them
for subject_label in subjects_to_analyze:
for fmri_file in glob(os.path.join(args.bids_dir,
func_files = glob(os.path.join(args.bids_dir,
"derivatives",
"sub-%s" % subject_label,
"func", "*_hmc_mni.nii.gz")
):
masker = input_data.NiftiLabelsMasker(
labels_img=atlas_filename,
standardize=True,
detrend=True,
verbose=3)
"func", "*_hmc_mni.nii.gz"))
for fmri_file in func_files:
time_series = masker.fit_transform(fmri_file)
out_file = os.path.split(fmri_file)[-1].replace("_hmc_mni.nii.gz",
"_time_series.tsv")
Expand Down