Skip to content

Commit

Permalink
feat: Move SimpleShowMaskRPT from niworkflows
Browse files Browse the repository at this point in the history
  • Loading branch information
effigies committed Oct 4, 2024
1 parent 6404af3 commit 59cb904
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
39 changes: 39 additions & 0 deletions nireports/interfaces/reporting/masks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Copyright The NiPreps Developers <[email protected]>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# We support and encourage derived works from this project, please read
# about our expectations at
#
# https://www.nipreps.org/community/licensing/
#
from nipype.interfaces.base import File

from .base import ReportingInterface, SegmentationRC, _SVGReportCapableInputSpec


class _SimpleShowMaskInputSpec(_SVGReportCapableInputSpec):
background_file = File(exists=True, mandatory=True, desc="file before")
mask_file = File(exists=True, mandatory=True, desc="file before")


class SimpleShowMaskRPT(SegmentationRC, ReportingInterface):
input_spec = _SimpleShowMaskInputSpec

def _post_run_hook(self, runtime):
self._anat_file = self.inputs.background_file
self._mask_file = self.inputs.mask_file
self._seg_files = [self.inputs.mask_file]
self._masked = True

return super()._post_run_hook(runtime)
31 changes: 31 additions & 0 deletions nireports/tests/test_interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,18 @@
from shutil import copy

import nibabel as nb
import nipype.pipeline.engine as pe
import numpy as np
import pytest
from templateflow.api import get as get_template

from nireports.interfaces.fmri import FMRISummary
from nireports.interfaces.nuisance import (
CompCorVariancePlot,
ConfoundsCorrelationPlot,
RaincloudPlot,
)
from nireports.interfaces.reporting.masks import SimpleShowMaskRPT
from nireports.tests.utils import _generate_raincloud_random_data


Expand Down Expand Up @@ -139,3 +142,31 @@ def test_FMRISummary(testdata_path, tmp_path, outdir):
from shutil import copy

copy(result.outputs.out_file, outdir / "fmriplot_nipype.svg")


def test_SimpleShowMaskRPT(tmp_path, outdir):
msk_rpt = pe.Node(
SimpleShowMaskRPT(
generate_report=True,
background_file=str(
get_template("OASIS30ANTs", resolution=1, desc=None, suffix="T1w")
),
mask_file=str(
get_template(
"OASIS30ANTs",
resolution=1,
desc="BrainCerebellumRegistration",
suffix="mask",
)
),
),
name="mask_rpt",
base_dir=str(tmp_path),
)

result = msk_rpt.run()

if outdir is not None:
from shutil import copy

copy(result.outputs.out_report, outdir / "simpleshowmask.svg")

0 comments on commit 59cb904

Please sign in to comment.