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

ENH: Tag memory based on data shape, annotate T2SMap #2898

Merged
merged 3 commits into from
Dec 11, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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
10 changes: 7 additions & 3 deletions fmriprep/workflows/bold/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import os

import nibabel as nb
import numpy as np
from nipype.interfaces import utility as niu
from nipype.interfaces.fsl import Split as FSLSplit
from nipype.pipeline import engine as pe
Expand Down Expand Up @@ -563,7 +564,7 @@ def init_func_preproc_wf(bold_file, has_fieldmap=False):
# create optimal combination, adaptive T2* map
bold_t2s_wf = init_bold_t2s_wf(
echo_times=tes,
mem_gb=mem_gb["resampled"],
mem_gb=mem_gb["filesize"],
omp_nthreads=omp_nthreads,
name="bold_t2smap_wf",
)
Expand Down Expand Up @@ -1320,8 +1321,11 @@ def _dpop(list_of_lists):


def _create_mem_gb(bold_fname):
bold_size_gb = os.path.getsize(bold_fname) / (1024**3)
bold_tlen = nb.load(bold_fname).shape[-1]
img = nb.load(bold_fname)
nvox = int(np.prod(img.shape, dtype='u8'))
# Assume tools will coerce to 8-byte floats to be safe
bold_size_gb = 8 * nvox / (1024**3)
bold_tlen = img.shape[-1]
mem_gb = {
"filesize": bold_size_gb,
"resampled": bold_size_gb * 4,
Expand Down
6 changes: 5 additions & 1 deletion fmriprep/workflows/bold/t2s.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,11 @@ def init_bold_t2s_wf(echo_times, mem_gb, omp_nthreads, name='bold_t2s_wf'):

LOGGER.log(25, 'Generating T2* map and optimally combined ME-EPI time series.')

t2smap_node = pe.Node(T2SMap(echo_times=list(echo_times)), name='t2smap_node')
t2smap_node = pe.Node(
T2SMap(echo_times=list(echo_times)),
name='t2smap_node',
mem_gb=2 * mem_gb * len(echo_times),
effigies marked this conversation as resolved.
Show resolved Hide resolved
)
# fmt:off
workflow.connect([
(inputnode, t2smap_node, [('bold_file', 'in_files'),
Expand Down