Skip to content

Commit 5f7654a

Browse files
committed
fix(reportlet): set vmax/vmin
1 parent b48fb60 commit 5f7654a

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

sdcflows/interfaces/reportlets.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ class FieldmapReportletInputSpec(reporting.ReportCapableInputSpec):
1212
reference = File(exists=True, mandatory=True, desc='input reference')
1313
fieldmap = File(exists=True, mandatory=True, desc='input fieldmap')
1414
mask = File(exists=True, desc='brain mask')
15+
out_report = File('report.svg', usedefault=True,
16+
desc='filename for the visual report')
1517

1618

1719
class FieldmapReportlet(reporting.ReportCapableInterface):
@@ -31,13 +33,17 @@ def _run_interface(self, runtime):
3133

3234
def _generate_report(self):
3335
"""Generate a reportlet."""
36+
import numpy as np
3437
NIWORKFLOWS_LOG.info('Generating visual report')
3538

3639
refnii = load_img(self.inputs.reference)
3740
fmapnii = load_img(self.inputs.fieldmap)
3841
contour_nii = load_img(self.inputs.mask) if isdefined(self.inputs.mask) else None
3942
mask_nii = threshold_img(refnii, 1e-3)
4043
cuts = cuts_from_bbox(contour_nii or mask_nii, cuts=self._n_cuts)
44+
fmapdata = fmapnii.get_fdata()
45+
vmax = max(fmapdata.max(), abs(fmapdata.min()))
46+
thres = np.percentile(fmapdata[fmapdata > 0], 5)
4147

4248
# Call composer
4349
compose_view(
@@ -53,7 +59,9 @@ def _generate_report(self):
5359
label='fieldmap (Hz)',
5460
contour=contour_nii,
5561
compress=False,
56-
plot_params={'cmap': 'coolwarm'}),
62+
plot_params={'cmap': 'coolwarm',
63+
'vmax': vmax,
64+
'vmin': -vmax}),
5765
out_file=self._out_report
5866
)
5967

0 commit comments

Comments
 (0)