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

Update to match neurodatascience/nipoppy:main #52

Merged
merged 1 commit into from
Apr 25, 2024
Merged
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
20 changes: 18 additions & 2 deletions nipoppy/extractors/fmriprep/run_FC.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,18 @@ def run_FC(

logger.info("Running FC assessment...")
logger.info("-"*50)

func_file = f"{fmriprep_dir}/{participant_id}/ses-{session_id}/func/{participant_id}_ses-{session_id}_{task}_{run}_{space}_desc-preproc_bold.nii.gz"
# check if the func file exists
if not os.path.exists(func_file):
logger.error(f"func file not found: {func_file}")
logger.error(f"Skipping participant: {participant_id}")
return

try:
for brain_atlas in brain_atlas_list:
logger.info('******** running ' + brain_atlas)
### extract time series
func_file = f"{fmriprep_dir}/{participant_id}/ses-{session_id}/func/{participant_id}_ses-{session_id}_{task}_{run}_{space}_desc-preproc_bold.nii.gz"
if 'schaefer' in brain_atlas:
time_series, labels = extract_timeseries(func_file, brain_atlas, confound_strategy)
elif brain_atlas=='DKT':
Expand All @@ -170,10 +176,11 @@ def run_FC(
if not os.path.exists(folder):
os.makedirs(folder)
np.save(f"{folder}/{participant_id}_ses-{session_id}_{task}_{space}_FC_{brain_atlas}.npy", FC)
logger.info(f"Successfully completed FC assessment for participant: {participant_id}")
except Exception as e:
logger.error(f"FC assessment failed with exceptions: {e}")
logger.error(f"Failed participant: {participant_id}")

logger.info(f"Successfully completed FC assessment for participant: {participant_id}")
logger.info("-"*75)
logger.info("")

Expand Down Expand Up @@ -226,6 +233,15 @@ def run(participant_id: str,
DKT_dir = f"{DATASET_ROOT}/derivatives/networks/0.9.0/output"
FC_dir = f"{output_dir}/FC"

# check if the func/ exists in fmriprep_dir
func_dir = f"{fmriprep_dir}/{participant_id}/ses-{session_id}/func/"
if not os.path.exists(func_dir):
logger.error(
f"func data not found: {func_dir}"
)
logger.error(f"Skipping participant: {participant_id}")
return

# assess FC
run_FC(
participant_id,
Expand Down
Loading