Hi all,
I have a python script that genreates the outputs AIF_ROI
and aif_plot
.
aif_plot
is a PNG-file and could be either one file or up to 4 separet files.where n could be 1 or up to four.
The question is how i get the nipype wrapper to handle a list of outputs from the output aif_plot
.
Here’s some of the code:
class aifCalcInputSpec(BaseInterfaceInputSpec):
conc_file = File(exists=True, desc='4D volume from where concentration curves are extracted', mandatory=True)
peakconc_file = File(exists=True, desc='3D volume whcich are used for displaying cluster result etc', mandatory=True)
brain_mask = File(exists=True, desc='Brain mask for the concentration data', mandatory=True)
ROI_file = File(exists=True, desc='The ROI from where the AIF is calculated', mandatory=True)
ireg_feat = File(exists=True, desc='Ireg feature for the data', mandatory=True)
auc_feat = File(exists=True, desc='AUC feature for the data', mandatory=True)
firstM_feat = File(exists=True, desc='First moment feature for the data', mandatory=True)
variables = File(exists=True, desc='The variables file containing baseline index', mandatory=True)
class aifCalcOutputSpec(TraitedSpec):
aif_ROI = File(exists=True, desc="The AIF ROI i 3D")
aif_plot = File(exists=True, desc="A plot for QA")
class aifCalc(BaseInterface):
input_spec = aifCalcInputSpec
output_spec = aifCalcOutputSpec
def _run_interface(self, runtime):
----CALCULATIONS------
nib.save(AIF_img, 'AIF_ROI.nii')
# Checking if it's one or several PNG file that should be saved
if len(unique_slices) > 1:
fileName = 'AIF_result' + str(n+1)
else:
fileName = 'AIF_result'
figure[0].savefig(fileName, dpi =300)
figure[0].clf()
plt.close(figure[0])
roiCalc = roiCalc + 1
return runtime
def _list_outputs(self):
outputs = self._outputs().get()
#Here's my own solutions but it doesnt work
aifResult_list = []
for f in os.listdir():
if f.startswith('AIF_result'):
aifResult_list.append(os.path.abspath(f))
outputs["aif_ROI"] = os.path.abspath('AIF_ROI.nii')
outputs["aif_plot"] = aifResult_list
return outputs
From this code I’m getting the error
FileNotFoundError: No such file or directory '['/home/brain/Documents/inph/test/registration/AIF_result1.png']' for output 'aif_plot' of a aifCalc interface
Appreciate any help!