Skip to content

Commit c0f8aab

Browse files
author
Monika_Utrosa_Skerjanec
committed
correct phaseEncoding issues & automate visualization and file renaming & combine echos
1 parent 7062ecd commit c0f8aab

162 files changed

Lines changed: 411 additions & 191198 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

build_singularity_img.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Build singularity image
2+
singularity build /my_images/fmriprep-25.2.3.simg docker://poldracklab/fmriprep:25.2.3

correct_PED.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/env python3
2+
# Time-stamp: <02-12-2025 m.utrosa@bcbl.eu>
3+
import json
4+
from bids import BIDSLayout
5+
from pathlib import Path
6+
7+
bids_root = "/home/mutrosa/Documents/projects/select_fMRI/data_MRI/sourcedata/raw"
8+
9+
# Initialize BIDS layout
10+
layout = BIDSLayout(bids_root, validate=False)
11+
12+
# Get json files of single-band reference images
13+
sbref_files = layout.get(suffix='sbref', extension='.json', return_type='filename')
14+
print(f"Found {len(sbref_files)} sbref files.")
15+
16+
for sbref_path in sbref_files:
17+
18+
# Identify the run number from file metadata
19+
entities = layout.parse_file_entities(sbref_path)
20+
run = entities.get("run", None)
21+
if run != "02" and run != 2:
22+
continue
23+
24+
with open(sbref_path, 'r') as f:
25+
meta = json.load(f)
26+
27+
# Modify PED only if it is exactly "j-"
28+
if meta.get("PhaseEncodingDirection") == "j-":
29+
meta["PhaseEncodingDirection"] = "i"
30+
with open(sbref_path, 'w') as f:
31+
json.dump(meta, f, indent=4)
32+
print(f"Updated PED in: {sbref_path}")
33+
else:
34+
print(f"Skipping {sbref_path}: PED is {meta.get('PhaseEncodingDirection')}")

fMRIprep_localizer.sh

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,21 @@ set -eo pipefail
77
# Running the code in an environment specific to the project
88
source activate localizer_fMRI
99

10-
# Activate the correct conda environment: conda activate dcm2bids
11-
subID="01"
12-
1310
# STEP 0
1411
## Curate the data automatically and manually (remove bad runs).
1512
## Bad runs are runs that were interrupted due to participant's request (bathroom break, discomfort, ...),
1613
## or a mistake while running the sequences (sound not coming through, response pad keys not working ...).
1714

1815
# STEP 1
16+
## Identify the subject
17+
subID="01"
18+
1919
## Run the standard fMRIprep preprocessing pipeline.
20-
echo "Starting MRI preprocessing ..."
21-
bash data_MRI/code/preproc_singleSUB.sh "$subID"
22-
echo "Completed STEP 1 ;)"
20+
echo "***** Starting MRI preprocessing for $subID *****"
21+
date
22+
bash data_MRI/code/preproc_singleSUB_docker.sh "$subID"
23+
echo "***** Completed preprocessing for $subID ;) *****"
24+
date
2325

24-
conda deactivate
26+
conda deactivate
27+
spd-say done

import_localizer.sh

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#! /usr/bin/env bash
2-
# Time-stamp: <2025-11-03 m.utrosa@bcbl.eu>
2+
# Time-stamp: <2025-12-09 m.utrosa@bcbl.eu>
33

44
set -eo pipefail
55
# -e => exits if any of the processes called generate a non-zero return code at the end.
@@ -10,12 +10,19 @@ source activate localizer_fMRI
1010

1111
# Subject-specific parameters
1212
subID=1
13-
sesID=3
13+
sesID=1
14+
15+
# Project-specific parameters
1416
project="SubCort_HighRes"
1517
task="localizer"
1618
homePath="/home/mutrosa/Documents/projects/select_fMRI"
17-
# acq_list=("DresdenNoFat" "DresdenWFat" "ME1TR880" "ME3TR1600" "ME3TR1100" "ME3TR850" "ME3TR700")
18-
acq_list=("DresdenNoFat175" "DresdenWFat175" "ME1TR780" "ME3TR1180" "ME3TR770" "ME3TR680")
19+
20+
# Session-specific parameters
21+
if (( sesID == 1 )); then
22+
acq_list=("DresdenNoFat" "DresdenWFat" "ME1TR880" "ME3TR1600" "ME3TR1100" "ME3TR850" "ME3TR700")
23+
else
24+
acq_list=("DresdenNoFat175" "DresdenWFat175" "ME1TR780" "ME3TR1180" "ME3TR770" "ME3TR680")
25+
fi
1926

2027
# STEP 0
2128
## Generate sidecar files to set up the configuration files.
@@ -26,6 +33,7 @@ acq_list=("DresdenNoFat175" "DresdenWFat175" "ME1TR780" "ME3TR1180" "ME3TR770" "
2633
# c.) Removes noise from functional scans using NORDIC.
2734
echo "STEP 1: Starting curation of MRI data ..."
2835
python -m scripts.import.import_MRI "$subID" "$sesID" "$project" "$homePath" "${acq_list[@]}"
36+
python -m scripts.import.optimal_combo "$subID" "$sesID" "$task" "$homePath"
2937
echo "Completed STEP 1 ;)"
3038

3139
# STEP 2: EVENTS
@@ -42,4 +50,5 @@ echo "STEP 3: Starting PHYSIO import..."
4250
python -m scripts.import.import_PHYSIO "$subID" "$sesID" "$project" "$task" "$homePath"
4351
echo "Completed STEP 3 ;)"
4452

45-
conda deactivate
53+
conda deactivate
54+
spd-say done

preproc_runs/FH_run-01/sub-01/figures/sub-01_ses-01_acq-DresdenNoFat_fmapid-auto00000_desc-pepolar_fieldmap.svg

Lines changed: 0 additions & 1892 deletions
This file was deleted.

preproc_runs/FH_run-01/sub-01/figures/sub-01_ses-01_acq-DresdenWFat_fmapid-auto00001_desc-pepolar_fieldmap.svg

Lines changed: 0 additions & 1892 deletions
This file was deleted.

preproc_runs/FH_run-01/sub-01/figures/sub-01_ses-01_acq-ME1TR880_fmapid-auto00002_desc-pepolar_fieldmap.svg

Lines changed: 0 additions & 1896 deletions
This file was deleted.

preproc_runs/FH_run-01/sub-01/figures/sub-01_ses-01_acq-ME3TR1100_fmapid-auto00005_desc-pepolar_fieldmap.svg

Lines changed: 0 additions & 1872 deletions
This file was deleted.

preproc_runs/FH_run-01/sub-01/figures/sub-01_ses-01_acq-ME3TR1600_fmapid-auto00006_desc-pepolar_fieldmap.svg

Lines changed: 0 additions & 1886 deletions
This file was deleted.

preproc_runs/FH_run-01/sub-01/figures/sub-01_ses-01_acq-ME3TR700_fmapid-auto00003_desc-pepolar_fieldmap.svg

Lines changed: 0 additions & 1892 deletions
This file was deleted.

0 commit comments

Comments
 (0)