Skip to content

Commit

Permalink
cleaned up base workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
tclose committed Mar 20, 2024
1 parent 57af6dc commit 4a7b2eb
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 35 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,4 @@ dmypy.json

/pydra/tasks/mriqc/interfaces
/pydra/tasks/mriqc/_version.py
/pydra/tasks/mriqc/auto
76 changes: 41 additions & 35 deletions pydra/tasks/mriqc/workflows/anatomical/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,24 +50,25 @@
with mock_config():
wf = afni_wf()
"""
from pydra import Workflow, Node
from pydra.engine import specs


from mriqc import config
from mriqc.interfaces import (
import pydra
from pydra import Workflow
from pydra.tasks.mriqc.auto import (
UploadIQMs,
ArtifactMask,
ComputeQI2,
ConformImage,
IQMFileSink,
RotationMask,
StructuralQC,
)
from mriqc.interfaces.reports import AddProvenance
from mriqc.interfaces.datalad import DataladIdentityInterface

from mriqc import config

# from mriqc.interfaces.reports import AddProvenance
# from mriqc.interfaces.datalad import DataladIdentityInterface
from mriqc.messages import BUILDING_WORKFLOW
from mriqc.workflows.utils import get_fwhmx
from mriqc.workflows.anatomical.output import init_anat_report_wf
from pydra.tasks.mriqc.workflows.utils import get_fwhmx
from pydra.tasks.mriqc.workflows.anatomical.output import init_anat_report_wf

# from nipype.interfaces import utility as niu
# from nipype.pipeline import engine as pe
Expand Down Expand Up @@ -107,7 +108,7 @@ def anat_qc_workflow(modality, name="anatMRIQC"):
config.loggers.workflow.info(message)

# Initialize workflow
workflow = pe.Workflow(
workflow = Workflow(
name=name, input_spec=["in_file"]
) # specifying `input_spec` to contain ["in_file"] makes a field accessible at workflow.lzin.in_file

Expand Down Expand Up @@ -214,33 +215,38 @@ def anat_qc_workflow(modality, name="anatMRIQC"):
])
# fmt: on

# Upload metrics
@pydra.mark.task
def upload_iqms(in_iqms, endpoint, auth_token, strict):
from mriqc.interfaces.webapi import UploadIQMs
# # Upload metrics
# @pydra.mark.task
# def upload_iqms(in_iqms, endpoint, auth_token, strict):
# from mriqc.interfaces.webapi import UploadIQMs

upldwf = UploadIQMs(
in_iqms=in_iqms, endpoint=endpoint, auth_token=auth_token, strict=strict
)
return upldwf.api_id
# upldwf = UploadIQMs(
# in_iqms=in_iqms, endpoint=endpoint, auth_token=auth_token, strict=strict
# )
# return upldwf.api_id

# fmt: off
@pydra.mark.task
def upload_metrics(endpoint, auth_token, strict, in_iqms):
upload_iqms_result = upload_iqms(in_iqms=in_iqms, endpoint=endpoint, auth_token=auth_token, strict=strict)
return upload_iqms_result
# # fmt: off
# @pydra.mark.task
# def upload_metrics(endpoint, auth_token, strict, in_iqms):
# upload_iqms_result = upload_iqms(in_iqms=in_iqms, endpoint=endpoint, auth_token=auth_token, strict=strict)
# return upload_iqms_result

# returns the result
workflow = upload_metrics(
endpoint=config.execution.webapi_url,
auth_token=config.execution.webapi_token,
strict=config.execution.upload_strict,
in_iqms=iqmswf.lzout.outputnode.out_file,
) # fmt: off
workflow.ad_connections([
(iqmswf, upldwf, [("outputnode.out_file", "in_iqms")]),
(upldwf, anat_report_wf, [("api_id", "inputnode.api_id")]),
])
workflow.add(
UploadIQMs(
endpoint=config.execution.webapi_url,
auth_token=config.execution.webapi_token,
strict=config.execution.upload_strict,
in_iqms=workflow.iqmswf.lzout.outputnode.out_file,
name="upldwf",
)
)
# workflow.ad_connections(
# [
# (iqmswf, upldwf, [("outputnode.out_file", "in_iqms")]),
# (upldwf, anat_report_wf, [("api_id", "inputnode.api_id")]),
# ]
# )

# # Original Code
# if not config.execution.no_sub:
Expand All @@ -262,7 +268,7 @@ def upload_metrics(endpoint, auth_token, strict, in_iqms):
# ])
# # fmt: on

# return workflow
return workflow


def spatial_normalization(name="SpatialNormalization"):
Expand Down

0 comments on commit 4a7b2eb

Please sign in to comment.