Skip to content

Refactor fMRIPrep to PETPrep #9

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

Merged
merged 2 commits into from
May 26, 2025
Merged
Show file tree
Hide file tree
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
16 changes: 8 additions & 8 deletions petprep/cli/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ def build_workflow(config_file, retval):
from niworkflows.utils.bids import collect_participants
from niworkflows.utils.misc import check_valid_fs_license

from fmriprep.reports.core import generate_reports
from fmriprep.utils.bids import check_pipeline_version
from petprep.reports.core import generate_reports
from petprep.utils.bids import check_pipeline_version

from .. import config, data
from ..utils.misc import check_deps
Expand All @@ -54,18 +54,18 @@ def build_workflow(config_file, retval):
retval['return_code'] = 1
retval['workflow'] = None

banner = [f'Running fMRIPrep version {version}']
banner = [f'Running PETPrep version {version}']
notice_path = data.load.readable('NOTICE')
if notice_path.exists():
banner[0] += '\n'
banner += [f'License NOTICE {"#" * 50}']
banner += [f'fMRIPrep {version}']
banner += [f'PETPrep {version}']
banner += notice_path.read_text().splitlines(keepends=False)[1:]
banner += ['#' * len(banner[1])]
build_log.log(25, f'\n{" " * 9}'.join(banner))

# warn if older results exist: check for dataset_description.json in output folder
msg = check_pipeline_version('fMRIPrep', version, petprep_dir / 'dataset_description.json')
msg = check_pipeline_version('PETPrep', version, petprep_dir / 'dataset_description.json')
if msg is not None:
build_log.warning(msg)

Expand Down Expand Up @@ -108,7 +108,7 @@ def build_workflow(config_file, retval):

# Build main workflow
init_msg = [
"Building fMRIPrep's workflow:",
"Building PETPrep's workflow:",
f'BIDS dataset path: {config.execution.bids_dir}.',
f'Participant list: {subject_list}.',
f'Run identifier: {config.execution.run_uuid}.',
Expand All @@ -133,13 +133,13 @@ def build_workflow(config_file, retval):
build_log.critical(
"""\
ERROR: Federal Information Processing Standard (FIPS) mode is enabled on your system. \
FreeSurfer (and thus fMRIPrep) cannot be used in FIPS mode. \
FreeSurfer (and thus PETPrep) cannot be used in FIPS mode. \
Contact your system administrator for assistance."""
)
else:
build_log.critical(
"""\
ERROR: a valid license file is required for FreeSurfer to run. fMRIPrep looked for an existing \
ERROR: a valid license file is required for FreeSurfer to run. PETPrep looked for an existing \
license file at several paths, in this order: 1) command line argument ``--fs-license-file``; \
2) ``$FS_LICENSE`` environment variable; and 3) the ``$FREESURFER_HOME/license.txt`` path. Get it \
(for free) by registering at https://surfer.nmr.mgh.harvard.edu/registration.html"""
Expand Down
8 changes: 4 additions & 4 deletions petprep/workflows/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# https://www.nipreps.org/community/licensing/
#
"""
fMRIPrep base processing workflows
PETPrep base processing workflows
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. autofunction:: init_fmriprep_wf
Expand Down Expand Up @@ -166,12 +166,12 @@ def init_single_subject_wf(subject_id: str):
init_resample_surfaces_wf,
)

from fmriprep.workflows.pet.base import init_pet_wf
from petprep.workflows.pet.base import init_pet_wf

workflow = Workflow(name=f'sub_{subject_id}_wf')
workflow.__desc__ = f"""
Results included in this manuscript come from preprocessing
performed using *fMRIPrep* {config.environment.version}
performed using *PETPrep* {config.environment.version}
(@fmriprep1; @fmriprep2; RRID:SCR_016216),
which is based on *Nipype* {config.environment.nipype_version}
(@nipype1; @nipype2; RRID:SCR_002502).
Expand Down Expand Up @@ -544,7 +544,7 @@ def init_single_subject_wf(subject_id: str):
for pet_series in pet_runs:
pet_cache = {}
if config.execution.derivatives:
from fmriprep.utils.bids import collect_derivatives, extract_entities
from petprep.utils.bids import collect_derivatives, extract_entities

entities = extract_entities(pet_series)

Expand Down
2 changes: 1 addition & 1 deletion petprep/workflows/pet/fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def init_pet_fit_wf(
"""
from niworkflows.engine.workflows import LiterateWorkflow as Workflow

from fmriprep.utils.misc import estimate_pet_mem_usage
from petprep.utils.misc import estimate_pet_mem_usage

if precomputed is None:
precomputed = {}
Expand Down
8 changes: 4 additions & 4 deletions petprep/workflows/pet/outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
from niworkflows.interfaces.fixes import FixHeaderApplyTransforms as ApplyTransforms
from niworkflows.utils.images import dseg_label

from fmriprep import config
from fmriprep.config import DEFAULT_MEMORY_MIN_GB
from fmriprep.interfaces import DerivativesDataSink
from fmriprep.interfaces.bids import BIDSURI
from petprep import config
from petprep.config import DEFAULT_MEMORY_MIN_GB
from petprep.interfaces import DerivativesDataSink
from petprep.interfaces.bids import BIDSURI


def prepare_timing_parameters(metadata: dict):
Expand Down
Loading