Optimal combination with t2smap

Optimal combination with t2smap#

Use t2smap [DuPre et al., 2021] to combine data.

import os
from glob import glob

import matplotlib.pyplot as plt
import numpy as np
from myst_nb import glue
from nilearn import image, plotting
from repo2data.repo2data import Repo2Data
from tedana import workflows

# Install the data if running locally, or point to cached data if running on neurolibre
DATA_REQ_FILE = os.path.join("../binder/data_requirement.json")

# Download data
repo2data = Repo2Data(DATA_REQ_FILE)
data_path = repo2data.install()
data_path = os.path.abspath(data_path[0])
---- repo2data starting ----
/opt/hostedtoolcache/Python/3.10.15/x64/lib/python3.10/site-packages/repo2data
Config from file :
../binder/data_requirement.json
Destination:
./../data/multi-echo-data-analysis

Info : ./../data/multi-echo-data-analysis already downloaded
/opt/hostedtoolcache/Python/3.10.15/x64/lib/python3.10/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html
  from .autonotebook import tqdm as notebook_tqdm
func_dir = os.path.join(data_path, "func/")
data_files = [
    os.path.join(
        func_dir,
        "sub-04570_task-rest_echo-1_space-scanner_desc-partialPreproc_bold.nii.gz",
    ),
    os.path.join(
        func_dir,
        "sub-04570_task-rest_echo-2_space-scanner_desc-partialPreproc_bold.nii.gz",
    ),
    os.path.join(
        func_dir,
        "sub-04570_task-rest_echo-3_space-scanner_desc-partialPreproc_bold.nii.gz",
    ),
    os.path.join(
        func_dir,
        "sub-04570_task-rest_echo-4_space-scanner_desc-partialPreproc_bold.nii.gz",
    ),
]
echo_times = [12.0, 28.0, 44.0, 60.0]
mask_file = os.path.join(
    func_dir, "sub-04570_task-rest_space-scanner_desc-brain_mask.nii.gz"
)
confounds_file = os.path.join(
    func_dir, "sub-04570_task-rest_desc-confounds_timeseries.tsv"
)

out_dir = os.path.join(data_path, "t2smap")
workflows.t2smap_workflow(
    data_files,
    echo_times,
    out_dir=out_dir,
    mask=mask_file,
    prefix="sub-04570_task-rest_space-scanner",
    fittype="curvefit",
)
INFO     t2smap:t2smap_workflow:252 Using output directory: /home/runner/work/multi-echo-data-analysis/multi-echo-data-analysis/data/multi-echo-data-analysis/t2smap
INFO     t2smap:t2smap_workflow:278 Loading input data: ['/home/runner/work/multi-echo-data-analysis/multi-echo-data-analysis/data/multi-echo-data-analysis/func/sub-04570_task-rest_echo-1_space-scanner_desc-partialPreproc_bold.nii.gz', '/home/runner/work/multi-echo-data-analysis/multi-echo-data-analysis/data/multi-echo-data-analysis/func/sub-04570_task-rest_echo-2_space-scanner_desc-partialPreproc_bold.nii.gz', '/home/runner/work/multi-echo-data-analysis/multi-echo-data-analysis/data/multi-echo-data-analysis/func/sub-04570_task-rest_echo-3_space-scanner_desc-partialPreproc_bold.nii.gz', '/home/runner/work/multi-echo-data-analysis/multi-echo-data-analysis/data/multi-echo-data-analysis/func/sub-04570_task-rest_echo-4_space-scanner_desc-partialPreproc_bold.nii.gz']
INFO     t2smap:t2smap_workflow:298 Using user-defined mask
INFO     utils:make_adaptive_mask:198 Echo-wise intensity thresholds for adaptive mask: [258.33994278 180.98638476 134.6796175   91.51006253]
WARNING  utils:make_adaptive_mask:227 734 voxels in user-defined mask do not have good signal. Removing voxels from mask.
INFO     t2smap:t2smap_workflow:306 Computing adaptive T2* map
2-echo monoexponential:   0%|          | 0/2224 [00:00<?, ?it/s]
2-echo monoexponential:   3%|▎         | 57/2224 [00:00<00:03, 568.98it/s]
2-echo monoexponential:   6%|▌         | 135/2224 [00:00<00:03, 692.82it/s]
2-echo monoexponential:  10%|▉         | 215/2224 [00:00<00:02, 741.32it/s]
2-echo monoexponential:  13%|█▎        | 296/2224 [00:00<00:02, 766.47it/s]
2-echo monoexponential:  17%|█▋        | 374/2224 [00:00<00:02, 769.78it/s]
2-echo monoexponential:  20%|██        | 455/2224 [00:00<00:02, 782.02it/s]
2-echo monoexponential:  24%|██▍       | 535/2224 [00:00<00:02, 785.00it/s]
2-echo monoexponential:  28%|██▊       | 614/2224 [00:00<00:02, 777.28it/s]
2-echo monoexponential:  31%|███       | 692/2224 [00:00<00:01, 774.32it/s]
2-echo monoexponential:  35%|███▍      | 770/2224 [00:01<00:01, 766.49it/s]
2-echo monoexponential:  38%|███▊      | 848/2224 [00:01<00:01, 768.96it/s]
2-echo monoexponential:  42%|████▏     | 926/2224 [00:01<00:01, 770.00it/s]
2-echo monoexponential:  45%|████▌     | 1004/2224 [00:01<00:01, 768.86it/s]
2-echo monoexponential:  49%|████▊     | 1084/2224 [00:01<00:01, 776.46it/s]
2-echo monoexponential:  52%|█████▏    | 1162/2224 [00:01<00:01, 768.33it/s]
2-echo monoexponential:  56%|█████▌    | 1241/2224 [00:01<00:01, 772.86it/s]
2-echo monoexponential:  59%|█████▉    | 1319/2224 [00:01<00:01, 773.26it/s]
2-echo monoexponential:  63%|██████▎   | 1397/2224 [00:01<00:01, 771.84it/s]
2-echo monoexponential:  66%|██████▋   | 1475/2224 [00:01<00:00, 772.90it/s]
2-echo monoexponential:  70%|██████▉   | 1553/2224 [00:02<00:00, 765.46it/s]
2-echo monoexponential:  73%|███████▎  | 1632/2224 [00:02<00:00, 771.66it/s]
2-echo monoexponential:  77%|███████▋  | 1710/2224 [00:02<00:00, 769.59it/s]
2-echo monoexponential:  80%|████████  | 1788/2224 [00:02<00:00, 771.92it/s]
2-echo monoexponential:  84%|████████▍ | 1869/2224 [00:02<00:00, 780.59it/s]
2-echo monoexponential:  88%|████████▊ | 1950/2224 [00:02<00:00, 786.98it/s]
2-echo monoexponential:  91%|█████████ | 2029/2224 [00:02<00:00, 781.29it/s]
2-echo monoexponential:  95%|█████████▍| 2108/2224 [00:02<00:00, 779.48it/s]
2-echo monoexponential:  98%|█████████▊| 2186/2224 [00:02<00:00, 765.70it/s]
2-echo monoexponential: 100%|██████████| 2224/2224 [00:02<00:00, 767.85it/s]

3-echo monoexponential:   0%|          | 0/1092 [00:00<?, ?it/s]
3-echo monoexponential:   4%|▍         | 48/1092 [00:00<00:02, 473.50it/s]
3-echo monoexponential:   9%|▉         | 98/1092 [00:00<00:02, 484.00it/s]
3-echo monoexponential:  14%|█▎        | 150/1092 [00:00<00:01, 500.23it/s]
3-echo monoexponential:  19%|█▊        | 203/1092 [00:00<00:01, 506.27it/s]
3-echo monoexponential:  23%|██▎       | 255/1092 [00:00<00:01, 508.12it/s]
3-echo monoexponential:  28%|██▊       | 306/1092 [00:00<00:01, 503.98it/s]
3-echo monoexponential:  33%|███▎      | 357/1092 [00:00<00:01, 501.42it/s]
3-echo monoexponential:  37%|███▋      | 408/1092 [00:00<00:01, 493.54it/s]
3-echo monoexponential:  42%|████▏     | 459/1092 [00:00<00:01, 494.58it/s]
3-echo monoexponential:  47%|████▋     | 510/1092 [00:01<00:01, 496.85it/s]
3-echo monoexponential:  51%|█████▏    | 561/1092 [00:01<00:01, 497.86it/s]
3-echo monoexponential:  56%|█████▌    | 611/1092 [00:01<00:00, 490.78it/s]
3-echo monoexponential:  61%|██████    | 664/1092 [00:01<00:00, 500.32it/s]
3-echo monoexponential:  65%|██████▌   | 715/1092 [00:01<00:00, 492.44it/s]
3-echo monoexponential:  70%|███████   | 765/1092 [00:01<00:00, 490.45it/s]
3-echo monoexponential:  75%|███████▍  | 815/1092 [00:01<00:00, 490.66it/s]
3-echo monoexponential:  79%|███████▉  | 865/1092 [00:01<00:00, 491.48it/s]
3-echo monoexponential:  84%|████████▍ | 918/1092 [00:01<00:00, 501.43it/s]
3-echo monoexponential:  89%|████████▉ | 970/1092 [00:01<00:00, 505.52it/s]
3-echo monoexponential:  93%|█████████▎| 1021/1092 [00:02<00:00, 506.02it/s]
3-echo monoexponential:  98%|█████████▊| 1072/1092 [00:02<00:00, 499.11it/s]
3-echo monoexponential: 100%|██████████| 1092/1092 [00:02<00:00, 498.05it/s]

4-echo monoexponential:   0%|          | 0/20176 [00:00<?, ?it/s]
4-echo monoexponential:   0%|          | 50/20176 [00:00<00:40, 499.65it/s]
4-echo monoexponential:   1%|          | 104/20176 [00:00<00:38, 520.68it/s]
4-echo monoexponential:   1%|          | 161/20176 [00:00<00:37, 539.27it/s]
4-echo monoexponential:   1%|          | 220/20176 [00:00<00:35, 558.75it/s]
4-echo monoexponential:   1%|▏         | 277/20176 [00:00<00:35, 559.76it/s]
4-echo monoexponential:   2%|▏         | 336/20176 [00:00<00:34, 567.11it/s]
4-echo monoexponential:   2%|▏         | 395/20176 [00:00<00:34, 573.91it/s]
4-echo monoexponential:   2%|▏         | 453/20176 [00:00<00:34, 569.62it/s]
4-echo monoexponential:   3%|▎         | 513/20176 [00:00<00:34, 577.63it/s]
4-echo monoexponential:   3%|▎         | 571/20176 [00:01<00:34, 575.42it/s]
4-echo monoexponential:   3%|▎         | 629/20176 [00:01<00:34, 567.77it/s]
4-echo monoexponential:   3%|▎         | 686/20176 [00:01<00:34, 567.09it/s]
4-echo monoexponential:   4%|▎         | 744/20176 [00:01<00:34, 570.34it/s]
4-echo monoexponential:   4%|▍         | 802/20176 [00:01<00:33, 572.12it/s]
4-echo monoexponential:   4%|▍         | 860/20176 [00:01<00:33, 573.69it/s]
4-echo monoexponential:   5%|▍         | 920/20176 [00:01<00:33, 579.30it/s]
4-echo monoexponential:   5%|▍         | 978/20176 [00:01<00:33, 569.86it/s]
4-echo monoexponential:   5%|▌         | 1036/20176 [00:01<00:34, 550.61it/s]
4-echo monoexponential:   5%|▌         | 1092/20176 [00:01<00:34, 548.10it/s]
4-echo monoexponential:   6%|▌         | 1148/20176 [00:02<00:34, 550.79it/s]
4-echo monoexponential:   6%|▌         | 1207/20176 [00:02<00:33, 561.82it/s]
4-echo monoexponential:   6%|▋         | 1267/20176 [00:02<00:33, 571.51it/s]
4-echo monoexponential:   7%|▋         | 1328/20176 [00:02<00:32, 582.04it/s]
4-echo monoexponential:   7%|▋         | 1391/20176 [00:02<00:31, 593.88it/s]
4-echo monoexponential:   7%|▋         | 1451/20176 [00:02<00:32, 576.35it/s]
4-echo monoexponential:   7%|▋         | 1509/20176 [00:02<00:33, 563.90it/s]
4-echo monoexponential:   8%|▊         | 1569/20176 [00:02<00:32, 573.84it/s]
4-echo monoexponential:   8%|▊         | 1629/20176 [00:02<00:32, 579.53it/s]
4-echo monoexponential:   8%|▊         | 1690/20176 [00:02<00:31, 586.85it/s]
4-echo monoexponential:   9%|▊         | 1751/20176 [00:03<00:31, 591.72it/s]
4-echo monoexponential:   9%|▉         | 1811/20176 [00:03<00:30, 593.53it/s]
4-echo monoexponential:   9%|▉         | 1872/20176 [00:03<00:30, 598.31it/s]
4-echo monoexponential:  10%|▉         | 1932/20176 [00:03<00:30, 598.60it/s]
4-echo monoexponential:  10%|▉         | 1992/20176 [00:03<00:31, 574.63it/s]
4-echo monoexponential:  10%|█         | 2050/20176 [00:03<00:31, 576.15it/s]
4-echo monoexponential:  10%|█         | 2109/20176 [00:03<00:31, 578.49it/s]
4-echo monoexponential:  11%|█         | 2169/20176 [00:03<00:30, 582.98it/s]
4-echo monoexponential:  11%|█         | 2232/20176 [00:03<00:30, 596.80it/s]
4-echo monoexponential:  11%|█▏        | 2294/20176 [00:03<00:29, 601.59it/s]
4-echo monoexponential:  12%|█▏        | 2356/20176 [00:04<00:29, 604.05it/s]
4-echo monoexponential:  12%|█▏        | 2418/20176 [00:04<00:29, 607.18it/s]
4-echo monoexponential:  12%|█▏        | 2481/20176 [00:04<00:28, 613.55it/s]
4-echo monoexponential:  13%|█▎        | 2543/20176 [00:04<00:28, 610.06it/s]
4-echo monoexponential:  13%|█▎        | 2605/20176 [00:04<00:30, 576.98it/s]
4-echo monoexponential:  13%|█▎        | 2664/20176 [00:04<00:30, 577.14it/s]
4-echo monoexponential:  14%|█▎        | 2726/20176 [00:04<00:29, 587.98it/s]
4-echo monoexponential:  14%|█▍        | 2786/20176 [00:04<00:29, 588.97it/s]
4-echo monoexponential:  14%|█▍        | 2849/20176 [00:04<00:28, 600.10it/s]
4-echo monoexponential:  14%|█▍        | 2911/20176 [00:05<00:28, 603.52it/s]
4-echo monoexponential:  15%|█▍        | 2972/20176 [00:05<00:28, 605.06it/s]
4-echo monoexponential:  15%|█▌        | 3035/20176 [00:05<00:27, 612.23it/s]
4-echo monoexponential:  15%|█▌        | 3098/20176 [00:05<00:27, 614.50it/s]
4-echo monoexponential:  16%|█▌        | 3160/20176 [00:05<00:27, 615.83it/s]
4-echo monoexponential:  16%|█▌        | 3222/20176 [00:05<00:28, 596.24it/s]
4-echo monoexponential:  16%|█▋        | 3282/20176 [00:05<00:28, 593.75it/s]
4-echo monoexponential:  17%|█▋        | 3342/20176 [00:05<00:28, 595.06it/s]
4-echo monoexponential:  17%|█▋        | 3403/20176 [00:05<00:28, 596.20it/s]
4-echo monoexponential:  17%|█▋        | 3464/20176 [00:05<00:27, 597.70it/s]
4-echo monoexponential:  17%|█▋        | 3527/20176 [00:06<00:27, 606.59it/s]
4-echo monoexponential:  18%|█▊        | 3590/20176 [00:06<00:27, 611.99it/s]
4-echo monoexponential:  18%|█▊        | 3652/20176 [00:06<00:27, 609.63it/s]
4-echo monoexponential:  18%|█▊        | 3713/20176 [00:06<00:27, 607.16it/s]
4-echo monoexponential:  19%|█▊        | 3777/20176 [00:06<00:26, 613.38it/s]
4-echo monoexponential:  19%|█▉        | 3839/20176 [00:06<00:26, 608.41it/s]
4-echo monoexponential:  19%|█▉        | 3900/20176 [00:06<00:27, 602.31it/s]
4-echo monoexponential:  20%|█▉        | 3961/20176 [00:06<00:27, 590.17it/s]
4-echo monoexponential:  20%|█▉        | 4021/20176 [00:06<00:27, 592.35it/s]
4-echo monoexponential:  20%|██        | 4082/20176 [00:06<00:27, 595.01it/s]
4-echo monoexponential:  21%|██        | 4142/20176 [00:07<00:27, 589.22it/s]
4-echo monoexponential:  21%|██        | 4202/20176 [00:07<00:27, 590.50it/s]
4-echo monoexponential:  21%|██        | 4264/20176 [00:07<00:26, 598.73it/s]
4-echo monoexponential:  21%|██▏       | 4328/20176 [00:07<00:26, 608.85it/s]
4-echo monoexponential:  22%|██▏       | 4389/20176 [00:07<00:26, 602.10it/s]
4-echo monoexponential:  22%|██▏       | 4452/20176 [00:07<00:25, 607.64it/s]
4-echo monoexponential:  22%|██▏       | 4514/20176 [00:07<00:25, 609.72it/s]
4-echo monoexponential:  23%|██▎       | 4575/20176 [00:07<00:25, 609.79it/s]
4-echo monoexponential:  23%|██▎       | 4636/20176 [00:07<00:25, 605.39it/s]
4-echo monoexponential:  23%|██▎       | 4697/20176 [00:07<00:26, 588.29it/s]
4-echo monoexponential:  24%|██▎       | 4756/20176 [00:08<00:26, 586.56it/s]
4-echo monoexponential:  24%|██▍       | 4817/20176 [00:08<00:25, 591.07it/s]
4-echo monoexponential:  24%|██▍       | 4877/20176 [00:08<00:25, 591.32it/s]
4-echo monoexponential:  24%|██▍       | 4938/20176 [00:08<00:25, 595.39it/s]
4-echo monoexponential:  25%|██▍       | 5001/20176 [00:08<00:25, 603.55it/s]
4-echo monoexponential:  25%|██▌       | 5064/20176 [00:08<00:24, 609.42it/s]
4-echo monoexponential:  25%|██▌       | 5129/20176 [00:08<00:24, 619.04it/s]
4-echo monoexponential:  26%|██▌       | 5192/20176 [00:08<00:24, 620.94it/s]
4-echo monoexponential:  26%|██▌       | 5255/20176 [00:08<00:24, 621.31it/s]
4-echo monoexponential:  26%|██▋       | 5318/20176 [00:09<00:23, 620.71it/s]
4-echo monoexponential:  27%|██▋       | 5381/20176 [00:09<00:24, 613.70it/s]
4-echo monoexponential:  27%|██▋       | 5443/20176 [00:09<00:24, 589.64it/s]
4-echo monoexponential:  27%|██▋       | 5503/20176 [00:09<00:24, 589.98it/s]
4-echo monoexponential:  28%|██▊       | 5564/20176 [00:09<00:24, 593.92it/s]
4-echo monoexponential:  28%|██▊       | 5624/20176 [00:09<00:24, 591.07it/s]
4-echo monoexponential:  28%|██▊       | 5686/20176 [00:09<00:24, 597.61it/s]
4-echo monoexponential:  29%|██▊       | 5751/20176 [00:09<00:23, 610.93it/s]
4-echo monoexponential:  29%|██▉       | 5815/20176 [00:09<00:23, 618.72it/s]
4-echo monoexponential:  29%|██▉       | 5877/20176 [00:09<00:23, 615.05it/s]
4-echo monoexponential:  29%|██▉       | 5939/20176 [00:10<00:23, 616.06it/s]
4-echo monoexponential:  30%|██▉       | 6001/20176 [00:10<00:23, 607.03it/s]
4-echo monoexponential:  30%|███       | 6062/20176 [00:10<00:23, 606.60it/s]
4-echo monoexponential:  30%|███       | 6123/20176 [00:10<00:23, 604.37it/s]
4-echo monoexponential:  31%|███       | 6184/20176 [00:10<00:23, 594.81it/s]
4-echo monoexponential:  31%|███       | 6244/20176 [00:10<00:24, 574.65it/s]
4-echo monoexponential:  31%|███       | 6303/20176 [00:10<00:23, 578.51it/s]
4-echo monoexponential:  32%|███▏      | 6361/20176 [00:10<00:23, 576.35it/s]
4-echo monoexponential:  32%|███▏      | 6420/20176 [00:10<00:23, 578.92it/s]
4-echo monoexponential:  32%|███▏      | 6482/20176 [00:10<00:23, 588.91it/s]
4-echo monoexponential:  32%|███▏      | 6544/20176 [00:11<00:22, 596.80it/s]
4-echo monoexponential:  33%|███▎      | 6606/20176 [00:11<00:22, 602.25it/s]
4-echo monoexponential:  33%|███▎      | 6667/20176 [00:11<00:22, 598.55it/s]
4-echo monoexponential:  33%|███▎      | 6727/20176 [00:11<00:22, 596.96it/s]
4-echo monoexponential:  34%|███▎      | 6790/20176 [00:11<00:22, 603.51it/s]
4-echo monoexponential:  34%|███▍      | 6851/20176 [00:11<00:22, 597.94it/s]
4-echo monoexponential:  34%|███▍      | 6911/20176 [00:11<00:22, 597.39it/s]
4-echo monoexponential:  35%|███▍      | 6971/20176 [00:11<00:22, 574.40it/s]
4-echo monoexponential:  35%|███▍      | 7029/20176 [00:11<00:23, 569.48it/s]
4-echo monoexponential:  35%|███▌      | 7090/20176 [00:11<00:22, 578.81it/s]
4-echo monoexponential:  35%|███▌      | 7149/20176 [00:12<00:22, 580.24it/s]
4-echo monoexponential:  36%|███▌      | 7208/20176 [00:12<00:22, 576.71it/s]
4-echo monoexponential:  36%|███▌      | 7270/20176 [00:12<00:21, 588.49it/s]
4-echo monoexponential:  36%|███▋      | 7332/20176 [00:12<00:21, 594.96it/s]
4-echo monoexponential:  37%|███▋      | 7394/20176 [00:12<00:21, 600.49it/s]
4-echo monoexponential:  37%|███▋      | 7455/20176 [00:12<00:21, 592.14it/s]
4-echo monoexponential:  37%|███▋      | 7515/20176 [00:12<00:21, 591.75it/s]
4-echo monoexponential:  38%|███▊      | 7575/20176 [00:12<00:21, 591.28it/s]
4-echo monoexponential:  38%|███▊      | 7636/20176 [00:12<00:21, 595.13it/s]
4-echo monoexponential:  38%|███▊      | 7696/20176 [00:13<00:21, 591.27it/s]
4-echo monoexponential:  38%|███▊      | 7756/20176 [00:13<00:21, 573.71it/s]
4-echo monoexponential:  39%|███▊      | 7814/20176 [00:13<00:21, 571.06it/s]
4-echo monoexponential:  39%|███▉      | 7872/20176 [00:13<00:21, 568.97it/s]
4-echo monoexponential:  39%|███▉      | 7931/20176 [00:13<00:21, 573.81it/s]
4-echo monoexponential:  40%|███▉      | 7990/20176 [00:13<00:21, 577.83it/s]
4-echo monoexponential:  40%|███▉      | 8048/20176 [00:13<00:21, 575.68it/s]
4-echo monoexponential:  40%|████      | 8111/20176 [00:13<00:20, 591.60it/s]
4-echo monoexponential:  41%|████      | 8173/20176 [00:13<00:20, 597.31it/s]
4-echo monoexponential:  41%|████      | 8233/20176 [00:13<00:20, 592.85it/s]
4-echo monoexponential:  41%|████      | 8295/20176 [00:14<00:19, 600.41it/s]
4-echo monoexponential:  41%|████▏     | 8356/20176 [00:14<00:19, 597.32it/s]
4-echo monoexponential:  42%|████▏     | 8416/20176 [00:14<00:19, 592.49it/s]
4-echo monoexponential:  42%|████▏     | 8478/20176 [00:14<00:19, 599.97it/s]
4-echo monoexponential:  42%|████▏     | 8539/20176 [00:14<00:19, 590.76it/s]
4-echo monoexponential:  43%|████▎     | 8599/20176 [00:14<00:20, 577.43it/s]
4-echo monoexponential:  43%|████▎     | 8657/20176 [00:14<00:19, 577.18it/s]
4-echo monoexponential:  43%|████▎     | 8715/20176 [00:14<00:20, 570.42it/s]
4-echo monoexponential:  43%|████▎     | 8775/20176 [00:14<00:19, 577.44it/s]
4-echo monoexponential:  44%|████▍     | 8836/20176 [00:14<00:19, 586.56it/s]
4-echo monoexponential:  44%|████▍     | 8895/20176 [00:15<00:19, 587.32it/s]
4-echo monoexponential:  44%|████▍     | 8954/20176 [00:15<00:19, 586.08it/s]
4-echo monoexponential:  45%|████▍     | 9017/20176 [00:15<00:18, 598.30it/s]
4-echo monoexponential:  45%|████▍     | 9077/20176 [00:15<00:18, 596.09it/s]
4-echo monoexponential:  45%|████▌     | 9139/20176 [00:15<00:18, 602.09it/s]
4-echo monoexponential:  46%|████▌     | 9203/20176 [00:15<00:17, 612.97it/s]
4-echo monoexponential:  46%|████▌     | 9265/20176 [00:15<00:17, 614.45it/s]
4-echo monoexponential:  46%|████▌     | 9327/20176 [00:15<00:17, 615.57it/s]
4-echo monoexponential:  47%|████▋     | 9389/20176 [00:15<00:18, 585.75it/s]
4-echo monoexponential:  47%|████▋     | 9449/20176 [00:16<00:18, 582.20it/s]
4-echo monoexponential:  47%|████▋     | 9508/20176 [00:16<00:18, 575.78it/s]
4-echo monoexponential:  47%|████▋     | 9567/20176 [00:16<00:18, 578.85it/s]
4-echo monoexponential:  48%|████▊     | 9628/20176 [00:16<00:18, 585.81it/s]
4-echo monoexponential:  48%|████▊     | 9687/20176 [00:16<00:17, 586.11it/s]
4-echo monoexponential:  48%|████▊     | 9749/20176 [00:16<00:17, 594.28it/s]
4-echo monoexponential:  49%|████▊     | 9810/20176 [00:16<00:17, 596.06it/s]
4-echo monoexponential:  49%|████▉     | 9871/20176 [00:16<00:17, 597.25it/s]
4-echo monoexponential:  49%|████▉     | 9935/20176 [00:16<00:16, 607.41it/s]
4-echo monoexponential:  50%|████▉     | 10000/20176 [00:16<00:16, 619.86it/s]
4-echo monoexponential:  50%|████▉     | 10063/20176 [00:17<00:16, 619.26it/s]
4-echo monoexponential:  50%|█████     | 10125/20176 [00:17<00:16, 609.22it/s]
4-echo monoexponential:  50%|█████     | 10186/20176 [00:17<00:17, 574.85it/s]
4-echo monoexponential:  51%|█████     | 10244/20176 [00:17<00:17, 573.10it/s]
4-echo monoexponential:  51%|█████     | 10304/20176 [00:17<00:17, 578.40it/s]
4-echo monoexponential:  51%|█████▏    | 10364/20176 [00:17<00:16, 584.21it/s]
4-echo monoexponential:  52%|█████▏    | 10423/20176 [00:17<00:16, 584.47it/s]
4-echo monoexponential:  52%|█████▏    | 10487/20176 [00:17<00:16, 597.88it/s]
4-echo monoexponential:  52%|█████▏    | 10549/20176 [00:17<00:15, 603.82it/s]
4-echo monoexponential:  53%|█████▎    | 10610/20176 [00:17<00:15, 605.27it/s]
4-echo monoexponential:  53%|█████▎    | 10671/20176 [00:18<00:15, 596.06it/s]
4-echo monoexponential:  53%|█████▎    | 10733/20176 [00:18<00:15, 601.86it/s]
4-echo monoexponential:  54%|█████▎    | 10797/20176 [00:18<00:15, 611.40it/s]
4-echo monoexponential:  54%|█████▍    | 10859/20176 [00:18<00:15, 607.13it/s]
4-echo monoexponential:  54%|█████▍    | 10921/20176 [00:18<00:15, 609.28it/s]
4-echo monoexponential:  54%|█████▍    | 10982/20176 [00:18<00:15, 585.90it/s]
4-echo monoexponential:  55%|█████▍    | 11041/20176 [00:18<00:15, 578.14it/s]
4-echo monoexponential:  55%|█████▌    | 11099/20176 [00:18<00:15, 578.25it/s]
4-echo monoexponential:  55%|█████▌    | 11157/20176 [00:18<00:15, 576.51it/s]
4-echo monoexponential:  56%|█████▌    | 11223/20176 [00:18<00:14, 598.64it/s]
4-echo monoexponential:  56%|█████▌    | 11284/20176 [00:19<00:14, 599.85it/s]
4-echo monoexponential:  56%|█████▌    | 11345/20176 [00:19<00:14, 591.85it/s]
4-echo monoexponential:  57%|█████▋    | 11405/20176 [00:19<00:14, 589.33it/s]
4-echo monoexponential:  57%|█████▋    | 11465/20176 [00:19<00:14, 590.82it/s]
4-echo monoexponential:  57%|█████▋    | 11526/20176 [00:19<00:14, 593.67it/s]
4-echo monoexponential:  57%|█████▋    | 11589/20176 [00:19<00:14, 601.43it/s]
4-echo monoexponential:  58%|█████▊    | 11652/20176 [00:19<00:14, 606.62it/s]
4-echo monoexponential:  58%|█████▊    | 11713/20176 [00:19<00:13, 606.93it/s]
4-echo monoexponential:  58%|█████▊    | 11774/20176 [00:19<00:15, 549.70it/s]
4-echo monoexponential:  59%|█████▊    | 11833/20176 [00:20<00:14, 558.64it/s]
4-echo monoexponential:  59%|█████▉    | 11892/20176 [00:20<00:14, 564.84it/s]
4-echo monoexponential:  59%|█████▉    | 11952/20176 [00:20<00:14, 573.71it/s]
4-echo monoexponential:  60%|█████▉    | 12013/20176 [00:20<00:13, 583.35it/s]
4-echo monoexponential:  60%|█████▉    | 12073/20176 [00:20<00:13, 585.70it/s]
4-echo monoexponential:  60%|██████    | 12135/20176 [00:20<00:13, 595.77it/s]
4-echo monoexponential:  60%|██████    | 12198/20176 [00:20<00:13, 605.50it/s]
4-echo monoexponential:  61%|██████    | 12261/20176 [00:20<00:12, 612.26it/s]
4-echo monoexponential:  61%|██████    | 12324/20176 [00:20<00:12, 616.10it/s]
4-echo monoexponential:  61%|██████▏   | 12386/20176 [00:20<00:12, 614.86it/s]
4-echo monoexponential:  62%|██████▏   | 12448/20176 [00:21<00:12, 615.73it/s]
4-echo monoexponential:  62%|██████▏   | 12510/20176 [00:21<00:12, 612.87it/s]
4-echo monoexponential:  62%|██████▏   | 12572/20176 [00:21<00:13, 566.15it/s]
4-echo monoexponential:  63%|██████▎   | 12633/20176 [00:21<00:13, 576.49it/s]
4-echo monoexponential:  63%|██████▎   | 12696/20176 [00:21<00:12, 590.29it/s]
4-echo monoexponential:  63%|██████▎   | 12757/20176 [00:21<00:12, 595.90it/s]
4-echo monoexponential:  64%|██████▎   | 12820/20176 [00:21<00:12, 604.37it/s]
4-echo monoexponential:  64%|██████▍   | 12883/20176 [00:21<00:11, 611.77it/s]
4-echo monoexponential:  64%|██████▍   | 12945/20176 [00:21<00:11, 611.99it/s]
4-echo monoexponential:  64%|██████▍   | 13007/20176 [00:21<00:11, 613.41it/s]
4-echo monoexponential:  65%|██████▍   | 13070/20176 [00:22<00:11, 615.79it/s]
4-echo monoexponential:  65%|██████▌   | 13132/20176 [00:22<00:11, 611.92it/s]
4-echo monoexponential:  65%|██████▌   | 13194/20176 [00:22<00:11, 608.30it/s]
4-echo monoexponential:  66%|██████▌   | 13255/20176 [00:22<00:11, 604.32it/s]
4-echo monoexponential:  66%|██████▌   | 13316/20176 [00:22<00:11, 597.31it/s]
4-echo monoexponential:  66%|██████▋   | 13376/20176 [00:22<00:11, 571.65it/s]
4-echo monoexponential:  67%|██████▋   | 13437/20176 [00:22<00:11, 580.55it/s]
4-echo monoexponential:  67%|██████▋   | 13497/20176 [00:22<00:11, 585.43it/s]
4-echo monoexponential:  67%|██████▋   | 13557/20176 [00:22<00:11, 589.08it/s]
4-echo monoexponential:  68%|██████▊   | 13619/20176 [00:23<00:10, 597.70it/s]
4-echo monoexponential:  68%|██████▊   | 13682/20176 [00:23<00:10, 605.48it/s]
4-echo monoexponential:  68%|██████▊   | 13745/20176 [00:23<00:10, 611.35it/s]
4-echo monoexponential:  68%|██████▊   | 13808/20176 [00:23<00:10, 614.55it/s]
4-echo monoexponential:  69%|██████▊   | 13870/20176 [00:23<00:10, 614.97it/s]
4-echo monoexponential:  69%|██████▉   | 13932/20176 [00:23<00:10, 611.95it/s]
4-echo monoexponential:  69%|██████▉   | 13995/20176 [00:23<00:10, 615.57it/s]
4-echo monoexponential:  70%|██████▉   | 14057/20176 [00:23<00:10, 610.84it/s]
4-echo monoexponential:  70%|██████▉   | 14119/20176 [00:23<00:10, 596.34it/s]
4-echo monoexponential:  70%|███████   | 14179/20176 [00:23<00:10, 584.41it/s]
4-echo monoexponential:  71%|███████   | 14238/20176 [00:24<00:10, 575.81it/s]
4-echo monoexponential:  71%|███████   | 14300/20176 [00:24<00:10, 586.22it/s]
4-echo monoexponential:  71%|███████   | 14361/20176 [00:24<00:09, 590.76it/s]
4-echo monoexponential:  71%|███████▏  | 14425/20176 [00:24<00:09, 604.53it/s]
4-echo monoexponential:  72%|███████▏  | 14492/20176 [00:24<00:09, 619.79it/s]
4-echo monoexponential:  72%|███████▏  | 14555/20176 [00:24<00:09, 621.33it/s]
4-echo monoexponential:  72%|███████▏  | 14618/20176 [00:24<00:08, 621.99it/s]
4-echo monoexponential:  73%|███████▎  | 14681/20176 [00:24<00:08, 616.96it/s]
4-echo monoexponential:  73%|███████▎  | 14743/20176 [00:24<00:08, 609.02it/s]
4-echo monoexponential:  73%|███████▎  | 14804/20176 [00:24<00:08, 607.74it/s]
4-echo monoexponential:  74%|███████▎  | 14865/20176 [00:25<00:09, 584.26it/s]
4-echo monoexponential:  74%|███████▍  | 14925/20176 [00:25<00:08, 588.03it/s]
4-echo monoexponential:  74%|███████▍  | 14985/20176 [00:25<00:08, 591.17it/s]
4-echo monoexponential:  75%|███████▍  | 15046/20176 [00:25<00:08, 593.20it/s]
4-echo monoexponential:  75%|███████▍  | 15108/20176 [00:25<00:08, 600.53it/s]
4-echo monoexponential:  75%|███████▌  | 15172/20176 [00:25<00:08, 609.77it/s]
4-echo monoexponential:  76%|███████▌  | 15234/20176 [00:25<00:08, 606.00it/s]
4-echo monoexponential:  76%|███████▌  | 15296/20176 [00:25<00:07, 610.05it/s]
4-echo monoexponential:  76%|███████▌  | 15360/20176 [00:25<00:07, 616.58it/s]
4-echo monoexponential:  76%|███████▋  | 15422/20176 [00:25<00:07, 609.18it/s]
4-echo monoexponential:  77%|███████▋  | 15485/20176 [00:26<00:07, 612.11it/s]
4-echo monoexponential:  77%|███████▋  | 15547/20176 [00:26<00:07, 608.70it/s]
4-echo monoexponential:  77%|███████▋  | 15608/20176 [00:26<00:07, 584.36it/s]
4-echo monoexponential:  78%|███████▊  | 15670/20176 [00:26<00:07, 591.74it/s]
4-echo monoexponential:  78%|███████▊  | 15734/20176 [00:26<00:07, 605.56it/s]
4-echo monoexponential:  78%|███████▊  | 15795/20176 [00:26<00:07, 584.53it/s]
4-echo monoexponential:  79%|███████▊  | 15855/20176 [00:26<00:07, 588.56it/s]
4-echo monoexponential:  79%|███████▉  | 15919/20176 [00:26<00:07, 601.82it/s]
4-echo monoexponential:  79%|███████▉  | 15983/20176 [00:26<00:06, 610.33it/s]
4-echo monoexponential:  80%|███████▉  | 16048/20176 [00:27<00:06, 619.82it/s]
4-echo monoexponential:  80%|███████▉  | 16111/20176 [00:27<00:06, 620.94it/s]
4-echo monoexponential:  80%|████████  | 16174/20176 [00:27<00:06, 608.20it/s]
4-echo monoexponential:  80%|████████  | 16236/20176 [00:27<00:06, 608.51it/s]
4-echo monoexponential:  81%|████████  | 16297/20176 [00:27<00:06, 591.94it/s]
4-echo monoexponential:  81%|████████  | 16357/20176 [00:27<00:06, 578.13it/s]
4-echo monoexponential:  81%|████████▏ | 16418/20176 [00:27<00:06, 584.51it/s]
4-echo monoexponential:  82%|████████▏ | 16477/20176 [00:27<00:06, 575.47it/s]
4-echo monoexponential:  82%|████████▏ | 16537/20176 [00:27<00:06, 581.00it/s]
4-echo monoexponential:  82%|████████▏ | 16598/20176 [00:27<00:06, 589.25it/s]
4-echo monoexponential:  83%|████████▎ | 16659/20176 [00:28<00:05, 595.07it/s]
4-echo monoexponential:  83%|████████▎ | 16725/20176 [00:28<00:05, 612.21it/s]
4-echo monoexponential:  83%|████████▎ | 16788/20176 [00:28<00:05, 615.71it/s]
4-echo monoexponential:  84%|████████▎ | 16850/20176 [00:28<00:05, 613.21it/s]
4-echo monoexponential:  84%|████████▍ | 16912/20176 [00:28<00:05, 606.15it/s]
4-echo monoexponential:  84%|████████▍ | 16973/20176 [00:28<00:05, 603.43it/s]
4-echo monoexponential:  84%|████████▍ | 17034/20176 [00:28<00:05, 572.15it/s]
4-echo monoexponential:  85%|████████▍ | 17097/20176 [00:28<00:05, 587.80it/s]
4-echo monoexponential:  85%|████████▌ | 17157/20176 [00:28<00:05, 576.48it/s]
4-echo monoexponential:  85%|████████▌ | 17215/20176 [00:29<00:05, 575.03it/s]
4-echo monoexponential:  86%|████████▌ | 17275/20176 [00:29<00:04, 581.26it/s]
4-echo monoexponential:  86%|████████▌ | 17335/20176 [00:29<00:04, 586.09it/s]
4-echo monoexponential:  86%|████████▌ | 17399/20176 [00:29<00:04, 601.65it/s]
4-echo monoexponential:  87%|████████▋ | 17460/20176 [00:29<00:04, 603.47it/s]
4-echo monoexponential:  87%|████████▋ | 17521/20176 [00:29<00:04, 595.31it/s]
4-echo monoexponential:  87%|████████▋ | 17583/20176 [00:29<00:04, 600.97it/s]
4-echo monoexponential:  87%|████████▋ | 17644/20176 [00:29<00:04, 578.03it/s]
4-echo monoexponential:  88%|████████▊ | 17703/20176 [00:29<00:04, 573.27it/s]
4-echo monoexponential:  88%|████████▊ | 17761/20176 [00:29<00:04, 570.61it/s]
4-echo monoexponential:  88%|████████▊ | 17820/20176 [00:30<00:04, 575.21it/s]
4-echo monoexponential:  89%|████████▊ | 17880/20176 [00:30<00:03, 581.11it/s]
4-echo monoexponential:  89%|████████▉ | 17942/20176 [00:30<00:03, 590.19it/s]
4-echo monoexponential:  89%|████████▉ | 18007/20176 [00:30<00:03, 605.66it/s]
4-echo monoexponential:  90%|████████▉ | 18070/20176 [00:30<00:03, 609.81it/s]
4-echo monoexponential:  90%|████████▉ | 18132/20176 [00:30<00:03, 606.12it/s]
4-echo monoexponential:  90%|█████████ | 18193/20176 [00:30<00:03, 594.44it/s]
4-echo monoexponential:  90%|█████████ | 18253/20176 [00:30<00:03, 571.54it/s]
4-echo monoexponential:  91%|█████████ | 18311/20176 [00:30<00:03, 568.27it/s]
4-echo monoexponential:  91%|█████████ | 18368/20176 [00:30<00:03, 568.59it/s]
4-echo monoexponential:  91%|█████████▏| 18425/20176 [00:31<00:03, 567.12it/s]
4-echo monoexponential:  92%|█████████▏| 18485/20176 [00:31<00:02, 576.48it/s]
4-echo monoexponential:  92%|█████████▏| 18544/20176 [00:31<00:02, 577.20it/s]
4-echo monoexponential:  92%|█████████▏| 18606/20176 [00:31<00:02, 589.07it/s]
4-echo monoexponential:  93%|█████████▎| 18666/20176 [00:31<00:02, 589.83it/s]
4-echo monoexponential:  93%|█████████▎| 18726/20176 [00:31<00:02, 575.40it/s]
4-echo monoexponential:  93%|█████████▎| 18784/20176 [00:31<00:02, 569.87it/s]
4-echo monoexponential:  93%|█████████▎| 18843/20176 [00:31<00:02, 574.25it/s]
4-echo monoexponential:  94%|█████████▎| 18901/20176 [00:31<00:02, 571.28it/s]
4-echo monoexponential:  94%|█████████▍| 18961/20176 [00:32<00:02, 577.26it/s]
4-echo monoexponential:  94%|█████████▍| 19023/20176 [00:32<00:01, 587.91it/s]
4-echo monoexponential:  95%|█████████▍| 19088/20176 [00:32<00:01, 603.89it/s]
4-echo monoexponential:  95%|█████████▍| 19149/20176 [00:32<00:01, 592.75it/s]
4-echo monoexponential:  95%|█████████▌| 19209/20176 [00:32<00:01, 573.97it/s]
4-echo monoexponential:  95%|█████████▌| 19267/20176 [00:32<00:01, 567.12it/s]
4-echo monoexponential:  96%|█████████▌| 19324/20176 [00:32<00:01, 567.71it/s]
4-echo monoexponential:  96%|█████████▌| 19381/20176 [00:32<00:01, 556.94it/s]
4-echo monoexponential:  96%|█████████▋| 19440/20176 [00:32<00:01, 566.34it/s]
4-echo monoexponential:  97%|█████████▋| 19502/20176 [00:32<00:01, 580.53it/s]
4-echo monoexponential:  97%|█████████▋| 19561/20176 [00:33<00:01, 571.12it/s]
4-echo monoexponential:  97%|█████████▋| 19621/20176 [00:33<00:00, 578.28it/s]
4-echo monoexponential:  98%|█████████▊| 19680/20176 [00:33<00:00, 580.18it/s]
4-echo monoexponential:  98%|█████████▊| 19744/20176 [00:33<00:00, 597.02it/s]
4-echo monoexponential:  98%|█████████▊| 19807/20176 [00:33<00:00, 605.09it/s]
4-echo monoexponential:  98%|█████████▊| 19868/20176 [00:33<00:00, 587.44it/s]
4-echo monoexponential:  99%|█████████▉| 19927/20176 [00:33<00:00, 577.53it/s]
4-echo monoexponential:  99%|█████████▉| 19985/20176 [00:33<00:00, 573.70it/s]
4-echo monoexponential:  99%|█████████▉| 20043/20176 [00:33<00:00, 571.10it/s]
4-echo monoexponential: 100%|█████████▉| 20101/20176 [00:33<00:00, 566.21it/s]
4-echo monoexponential: 100%|█████████▉| 20158/20176 [00:34<00:00, 563.61it/s]
4-echo monoexponential: 100%|██████████| 20176/20176 [00:34<00:00, 591.39it/s]
INFO     t2smap:t2smap_workflow:319 Calculating model fit quality metrics
/opt/hostedtoolcache/Python/3.10.15/x64/lib/python3.10/site-packages/tedana/decay.py:541: RuntimeWarning: Mean of empty slice
  rmse_map = np.nanmean(rmse, axis=1)
INFO     t2smap:t2smap_workflow:331 Computing optimal combination
INFO     combine:make_optcom:192 Optimally combining data with voxel-wise T2* estimates
INFO     t2smap:t2smap_workflow:389 Workflow completed
out_files = sorted(glob(os.path.join(out_dir, "*")))
out_files = [os.path.basename(f) for f in out_files]
print("\n".join(out_files))
sub-04570_task-rest_space-scanner_S0map.nii.gz
sub-04570_task-rest_space-scanner_T2starmap.nii.gz
sub-04570_task-rest_space-scanner_dataset_description.json
sub-04570_task-rest_space-scanner_desc-confounds_timeseries.tsv
sub-04570_task-rest_space-scanner_desc-limited_S0map.nii.gz
sub-04570_task-rest_space-scanner_desc-limited_T2starmap.nii.gz
sub-04570_task-rest_space-scanner_desc-optcom_bold.nii.gz
sub-04570_task-rest_space-scanner_desc-rmse_statmap.nii.gz
sub-04570_task-rest_space-scanner_desc-tedana_registry.json
fig, ax = plt.subplots(figsize=(16, 8))
plotting.plot_stat_map(
    os.path.join(out_dir, "sub-04570_task-rest_space-scanner_T2starmap.nii.gz"),
    vmax=0.6,
    draw_cross=False,
    bg_img=None,
    figure=fig,
    axes=ax,
)
glue("figure_t2starmap", fig, display=False)
<Figure size 1600x800 with 5 Axes>

Fig. 20 T2* map estimated from multi-echo data using tedana’s t2smap_workflow().#

fig, ax = plt.subplots(figsize=(16, 8))
plotting.plot_stat_map(
    os.path.join(out_dir, "sub-04570_task-rest_space-scanner_S0map.nii.gz"),
    vmax=8000,
    draw_cross=False,
    bg_img=None,
    figure=fig,
    axes=ax,
)
glue("figure_s0map", fig, display=False)
<Figure size 1600x800 with 5 Axes>

Fig. 21 S0 map estimated from multi-echo data using tedana’s t2smap_workflow().#

fig, axes = plt.subplots(figsize=(16, 15), nrows=5)
plotting.plot_epi(
    image.mean_img(data_files[0]),
    draw_cross=False,
    bg_img=None,
    cut_coords=[-10, 0, 10, 20, 30, 40, 50, 60, 70],
    display_mode="z",
    figure=fig,
    axes=axes[0],
)
plotting.plot_epi(
    image.mean_img(data_files[1]),
    draw_cross=False,
    bg_img=None,
    cut_coords=[-10, 0, 10, 20, 30, 40, 50, 60, 70],
    display_mode="z",
    figure=fig,
    axes=axes[1],
)
plotting.plot_epi(
    image.mean_img(data_files[2]),
    draw_cross=False,
    bg_img=None,
    cut_coords=[-10, 0, 10, 20, 30, 40, 50, 60, 70],
    display_mode="z",
    figure=fig,
    axes=axes[2],
)
plotting.plot_epi(
    image.mean_img(data_files[3]),
    draw_cross=False,
    bg_img=None,
    cut_coords=[-10, 0, 10, 20, 30, 40, 50, 60, 70],
    display_mode="z",
    figure=fig,
    axes=axes[3],
)
plotting.plot_epi(
    image.mean_img(
        os.path.join(
            out_dir, "sub-04570_task-rest_space-scanner_desc-optcom_bold.nii.gz"
        )
    ),
    draw_cross=False,
    bg_img=None,
    cut_coords=[-10, 0, 10, 20, 30, 40, 50, 60, 70],
    display_mode="z",
    figure=fig,
    axes=axes[4],
)
glue("figure_t2smap_epi_plots", fig, display=False)
<Figure size 1600x1500 with 50 Axes>

Fig. 22 Mean map of each of the echoes in the original data, along with the mean map of the optimally combined data.#

te30_tsnr = image.math_img(
    "(np.nanmean(img, axis=3) / np.nanstd(img, axis=3)) * mask",
    img=data_files[1],
    mask=mask_file,
)
oc_tsnr = image.math_img(
    "(np.nanmean(img, axis=3) / np.nanstd(img, axis=3)) * mask",
    img=os.path.join(
        out_dir, "sub-04570_task-rest_space-scanner_desc-optcom_bold.nii.gz"
    ),
    mask=mask_file,
)
vmax = np.nanmax(np.abs(oc_tsnr.get_fdata()))

fig, axes = plt.subplots(figsize=(10, 8), nrows=2)
plotting.plot_stat_map(
    te30_tsnr,
    draw_cross=False,
    bg_img=None,
    threshold=0.1,
    cut_coords=[0, 10, 10],
    vmax=vmax,
    symmetric_cbar=False,
    figure=fig,
    axes=axes[0],
)
axes[0].set_title("TE30 TSNR", fontsize=16)
plotting.plot_stat_map(
    oc_tsnr,
    draw_cross=False,
    bg_img=None,
    threshold=0.1,
    cut_coords=[0, 10, 10],
    vmax=vmax,
    symmetric_cbar=False,
    figure=fig,
    axes=axes[1],
)
axes[1].set_title("Optimal Combination TSNR", fontsize=16)
glue("figure_t2smap_t2snr", fig, display=False)
<string>:1: RuntimeWarning: invalid value encountered in divide
/opt/hostedtoolcache/Python/3.10.15/x64/lib/python3.10/site-packages/nilearn/plotting/img_plotting.py:1317: UserWarning: Non-finite values detected. These values will be replaced with zeros.
  safe_get_data(stat_map_img, ensure_finite=True),
<Figure size 1000x800 with 10 Axes>

Fig. 23 TSNR map of each of the echoes in the original data, along with the TSNR map of the optimally combined data.#

fig, ax = plt.subplots(figsize=(16, 8))
plotting.plot_carpet(
    data_files[1],
    figure=fig,
    axes=ax,
)
glue("figure_echo2_carpet", fig, display=False)
<Figure size 1600x800 with 1 Axes>

Fig. 24 Carpet plot of the second echo’s data.#

fig, ax = plt.subplots(figsize=(16, 8))
plotting.plot_carpet(
    os.path.join(out_dir, "sub-04570_task-rest_space-scanner_desc-optcom_bold.nii.gz"),
    axes=ax,
)
glue("figure_optcom_carpet", fig, display=False)
<Figure size 1600x800 with 1 Axes>

Fig. 25 Carpet plot of the optimally combined data.#