Writing a CommandLineInputSpec using name_source

Hey all,

I hope anyone can give me some help with the following.

I am trying to write an CommandLineInputSpec for synthstrip-docker.

For my nipype pipeline, I first ran into errors because I did not define an out_file in the pipeline. So, I decided to change the input spec to autogenerate it, like so:

class SynthstripInputSpec(CommandLineInputSpec):
    in_file = File(
        desc="input image to skullstrip",
        exists=True,
        argstr="-i %s",
        position=0,
        mandatory=True,
        copyfile=False
    )
    out_file = File(
        desc="save stripped image to file",
        argstr="-o %s",
        exists=False,
        genfile = True,
        position=1,
        name_source=["in_file"],
        name_template="%s_bet",
        hash_files=False,
        keep_extension=True
    )
    # ...

Now, synthstrip does run successfully but the files are not handled properly. Inside the scratch folder, I found that the command does not take the folder location into account and only copies the file names:

synthstrip-docker -i [BASEFOLDER_HERE]/scratch/sub-p01/coreg_and_norm_wf/skull_strip/sub-p01_ses-predbs_pet_autobox.nii.gz -o sub-p01_ses-predbs_pet_autobox_bet.nii.gz -m sub-p01_ses-predbs_pet_autobox_mask.nii.gz -d sub-p01_ses-predbs_pet_autobox_dt.nii.gz --no-csf

Does anyone know how I should solve this?

Kind regards,

-Jelle

Ah, took me a while but I got it to work.

I borrowed the FSLCommand interface and used the _gen_filename(self, name) implementation from fsl.bet.