@@ -3,8 +3,7 @@ jupytext:
33 text_representation :
44 extension : .md
55 format_name : myst
6- format_version : 0.13
7- jupytext_version : 1.10.3
6+ jupytext_version : 1.18.1
87kernelspec :
98 display_name : Python 3
109 language : python
@@ -16,51 +15,43 @@ kernelspec:
1615Use ` t2smap ` {cite: p }` DuPre2021 ` to combine data.
1716
1817``` {code-cell} ipython3
18+ import json
1919import os
2020from glob import glob
2121
2222import matplotlib.pyplot as plt
23+ import nibabel as nb
2324import numpy as np
2425from myst_nb import glue
2526from nilearn import image, plotting
26- from repo2data.repo2data import Repo2Data
2727from tedana import workflows
2828
29- # Install the data if running locally, or point to cached data if running on neurolibre
30- DATA_REQ_FILE = os.path.join("../binder/data_requirement.json")
31-
32- # Download data
33- repo2data = Repo2Data(DATA_REQ_FILE)
34- data_path = repo2data.install()
35- data_path = os.path.abspath(data_path[0])
29+ data_path = os.path.abspath('../DATA')
3630```
3731
3832``` {code-cell} ipython3
39- func_dir = os.path.join(data_path, "func/")
40- data_files = [
41- os.path.join(
42- func_dir,
43- "sub-04570_task-rest_echo-1_space-scanner_desc-partialPreproc_bold.nii.gz",
44- ),
45- os.path.join(
46- func_dir,
47- "sub-04570_task-rest_echo-2_space-scanner_desc-partialPreproc_bold.nii.gz",
48- ),
49- os.path.join(
50- func_dir,
51- "sub-04570_task-rest_echo-3_space-scanner_desc-partialPreproc_bold.nii.gz",
52- ),
53- os.path.join(
54- func_dir,
55- "sub-04570_task-rest_echo-4_space-scanner_desc-partialPreproc_bold.nii.gz",
33+ func_dir = os.path.join(data_path, "ds006185/sub-24053/ses-1/func/")
34+ data_files = sorted(
35+ glob(
36+ os.path.join(
37+ func_dir,
38+ "sub-24053_ses-1_task-rat_rec-nordic_dir-PA_run-01_echo-*_part-mag_desc-preproc_bold.nii.gz",
39+ ),
5640 ),
57- ]
58- echo_times = [12.0, 28.0, 44.0, 60.0]
41+ )
42+ echo_times = []
43+ for f in data_files:
44+ json_file = f.replace('.nii.gz', '.json')
45+ with open(json_file, 'r') as fo:
46+ metadata = json.load(fo)
47+ echo_times.append(metadata['EchoTime'] * 1000)
5948mask_file = os.path.join(
60- func_dir, "sub-04570_task-rest_space-scanner_desc-brain_mask.nii.gz"
49+ func_dir,
50+ "sub-24053_ses-1_task-rat_rec-nordic_dir-PA_run-01_part-mag_desc-brain_mask.nii.gz"
6151)
6252confounds_file = os.path.join(
63- func_dir, "sub-04570_task-rest_desc-confounds_timeseries.tsv"
53+ func_dir,
54+ "sub-24053_ses-1_task-rat_rec-nordic_dir-PA_run-01_part-mag_desc-confounds_timeseries.tsv",
6455)
6556
6657out_dir = os.path.join(data_path, "t2smap")
@@ -72,8 +63,9 @@ workflows.t2smap_workflow(
7263 echo_times,
7364 out_dir=out_dir,
7465 mask=mask_file,
75- prefix="sub-04570_task-rest_space-scanner",
76- fittype="curvefit",
66+ prefix="sub-24053_ses-1_task-rat_rec-nordic_dir-PA_run-01",
67+ fittype="loglin",
68+ overwrite=True,
7769)
7870```
7971
@@ -86,7 +78,7 @@ print("\n".join(out_files))
8678``` {code-cell} ipython3
8779fig, ax = plt.subplots(figsize=(16, 8))
8880plotting.plot_stat_map(
89- os.path.join(out_dir, "sub-04570_task-rest_space-scanner_T2starmap .nii.gz"),
81+ os.path.join(out_dir, "sub-24053_ses-1_task-rat_rec-nordic_dir-PA_run-01_T2starmap .nii.gz"),
9082 vmax=0.6,
9183 draw_cross=False,
9284 bg_img=None,
@@ -106,7 +98,7 @@ T2* map estimated from multi-echo data using tedana's {py:func}`~tedana.workflow
10698``` {code-cell} ipython3
10799fig, ax = plt.subplots(figsize=(16, 8))
108100plotting.plot_stat_map(
109- os.path.join(out_dir, "sub-04570_task-rest_space-scanner_S0map .nii.gz"),
101+ os.path.join(out_dir, "sub-24053_ses-1_task-rat_rec-nordic_dir-PA_run-01_S0map .nii.gz"),
110102 vmax=8000,
111103 draw_cross=False,
112104 bg_img=None,
@@ -164,7 +156,7 @@ plotting.plot_epi(
164156plotting.plot_epi(
165157 image.mean_img(
166158 os.path.join(
167- out_dir, "sub-04570_task-rest_space-scanner_desc -optcom_bold.nii.gz"
159+ out_dir, "sub-24053_ses-1_task-rat_rec-nordic_dir-PA_run-01_desc -optcom_bold.nii.gz"
168160 )
169161 ),
170162 draw_cross=False,
@@ -193,7 +185,7 @@ te30_tsnr = image.math_img(
193185oc_tsnr = image.math_img(
194186 "(np.nanmean(img, axis=3) / np.nanstd(img, axis=3)) * mask",
195187 img=os.path.join(
196- out_dir, "sub-04570_task-rest_space-scanner_desc -optcom_bold.nii.gz"
188+ out_dir, "sub-24053_ses-1_task-rat_rec-nordic_dir-PA_run-01_desc -optcom_bold.nii.gz"
197189 ),
198190 mask=mask_file,
199191)
@@ -254,7 +246,7 @@ Carpet plot of the second echo's data.
254246``` {code-cell} ipython3
255247fig, ax = plt.subplots(figsize=(16, 8))
256248plotting.plot_carpet(
257- os.path.join(out_dir, "sub-04570_task-rest_space-scanner_desc -optcom_bold.nii.gz"),
249+ os.path.join(out_dir, "sub-24053_ses-1_task-rat_rec-nordic_dir-PA_run-01_desc -optcom_bold.nii.gz"),
258250 axes=ax,
259251)
260252glue("figure_optcom_carpet", fig, display=False)
0 commit comments