[Solved] Datasink.inputs.substitutions fails for numbers > 9

Hi there,

I’m having trouble getting the substitutions working for the datasink module. Here’s an example:
I want the output of the 2nd level contrasts to be changed from ‘_con_n’ to a specific name. This works only up to ‘_con_9’, after which it spits out the same name as for ‘_con_1’ with a suffix (0 to the last one).
How can I get it to work?

substitutions = [('_con_1', 'speech_vowel'),
                 ('_con_2', 'speaker_vowel'),
                 ('_con_10', 'interaction_spe-con-vow_vs_spk-con-vow'),
                 ('_con_11', 'all-sounds_vs_instruct'),
                 ]

Hi @Glad, could you post your report.rst from the node’s working directory?

Hi @mgxd, here is the report.rst for _con_10, the first contrast where it goes awry. The substitutions seem to be specified correctly, yet the out_file under the Execution Options shows the faulty substitution.

Node: datasink (io)
===================

 Hierarchy : l2analysisSm4.datasink
 Exec ID : datasink.a09

Original Inputs
---------------

* _outputs : {'@con': '/data/pt_nmc002/TDMGB_FMRI/tmp/l2analysisSm4/_con_10/level2conestimate/con_0001.nii', '@spm_mat': '/data/pt_nmc002/TDMGB_FMRI/tmp/l2analysisSm4/_con_10/level2conestimate/SPM.mat', '@T': '/data/pt_nmc002/TDMGB_FMRI/tmp/l2analysisSm4/_con_10/level2conestimate/spmT_0001.nii'}
* base_directory : /data/pt_nmc002/TDMGB_FMRI/
* bucket : <undefined>
* container : 2ndLevel/spespk_good_norm_sm4_28subs_subst
* creds_path : <undefined>
* encrypt_bucket_keys : <undefined>
* ignore_exception : False
* local_copy : <undefined>
* parameterization : True
* regexp_substitutions : <undefined>
* remove_dest_dir : False
* strip_dir : <undefined>
* substitutions : [('_con_1', 'speech_vowel'), ('_con_2', 'speaker_vowel'), ('_con_3', 'speech_consonant'), ('_con_4', 'speaker_consonant'), ('_con_5', 'instruction'), ('_con_6', 'speech_vow+cons'), ('_con_7', 'speaker_vow+cons'), ('_con_8', 'speech_vs_speaker'), ('_con_9', 'speaker_vs_speech'), ('_con_10', 'interaction_spe-con-vow_vs_spk-con-vow'), ('_con_11', 'all-sounds_vs_instruct'), ('_con_12', 'simp_eff_speech_vow-con'), ('_con_13', 'simp_eff_speech_con-vow'), ('_con_14', 'simp_eff_speaker_vow-con'), ('_con_15', 'simp_eff_speaker_con-vow'), ('_con_16', 'simp_eff_vow_spe-spk'), ('_con_17', 'simp_eff_vow_spk-spe'), ('_con_18', 'simp_eff_con_spe-spk'), ('_con_19', 'simp_eff_con_spk-spe'), ('_con_20', 'main_eff_con_spe+spk'), ('_con_21', 'main_eff_vow_spe+spk')]

Execution Inputs
----------------

* _outputs : {'@con': '/data/pt_nmc002/TDMGB_FMRI/tmp/l2analysisSm4/_con_10/level2conestimate/con_0001.nii', '@spm_mat': '/data/pt_nmc002/TDMGB_FMRI/tmp/l2analysisSm4/_con_10/level2conestimate/SPM.mat', '@T': '/data/pt_nmc002/TDMGB_FMRI/tmp/l2analysisSm4/_con_10/level2conestimate/spmT_0001.nii'}
* base_directory : /data/pt_nmc002/TDMGB_FMRI/
* bucket : <undefined>
* container : 2ndLevel/spespk_good_norm_sm4_28subs_subst
* creds_path : <undefined>
* encrypt_bucket_keys : <undefined>
* ignore_exception : False
* local_copy : <undefined>
* parameterization : True
* regexp_substitutions : <undefined>
* remove_dest_dir : False
* strip_dir : <undefined>
* substitutions : [('_con_1', 'speech_vowel'), ('_con_2', 'speaker_vowel'), ('_con_3', 'speech_consonant'), ('_con_4', 'speaker_consonant'), ('_con_5', 'instruction'), ('_con_6', 'speech_vow+cons'), ('_con_7', 'speaker_vow+cons'), ('_con_8', 'speech_vs_speaker'), ('_con_9', 'speaker_vs_speech'), ('_con_10', 'interaction_spe-con-vow_vs_spk-con-vow'), ('_con_11', 'all-sounds_vs_instruct'), ('_con_12', 'simp_eff_speech_vow-con'), ('_con_13', 'simp_eff_speech_con-vow'), ('_con_14', 'simp_eff_speaker_vow-con'), ('_con_15', 'simp_eff_speaker_con-vow'), ('_con_16', 'simp_eff_vow_spe-spk'), ('_con_17', 'simp_eff_vow_spk-spe'), ('_con_18', 'simp_eff_con_spe-spk'), ('_con_19', 'simp_eff_con_spk-spe'), ('_con_20', 'main_eff_con_spe+spk'), ('_con_21', 'main_eff_vow_spe+spk')]

Execution Outputs
-----------------

* out_file : ['/data/pt_nmc002/TDMGB_FMRI/2ndLevel/spespk_good_norm_sm4_28subs_subst/speech_vowel0/con_0001.nii', '/data/pt_nmc002/TDMGB_FMRI/2ndLevel/spespk_good_norm_sm4_28subs_subst/speech_vowel0/SPM.mat', '/data/pt_nmc002/TDMGB_FMRI/2ndLevel/spespk_good_norm_sm4_28subs_subst/speech_vowel0/spmT_0001.nii']

Runtime info
------------

* duration : 0.07512
* hostname : pyrit.cbs.mpg.de

Environment
~~~~~~~~~~~

* DISPLAY : localhost:13.0
* ENVLIST : spm=12.6685
* FB_COLORIZE : 0
* HISTCONTROL : ignoreboth
* HISTSIZE : 50000
* HOME : /home/raid2/mihai
* KRB5CCNAME : FILE:/tmp/krb5cc_12560_rE4FXWEyxR
* LANG : en_US.UTF-8
* LC_ALL : en_US.UTF-8
* LOCALPROFILE : cbs-fb
* LOGNAME : mihai
* MAIL : /var/mail/mihai
* MANPAGER : /usr/bin/less
* PAGER : /usr/bin/less
* PATH : /afs/cbs.mpg.de/software/fsl/currentversion.ubuntu-xenial-amd64/ubuntu-xenial-amd64/bin:/nobackup/archimedes1/Glad/anaconda2_serverwide/bin:/afs/cbs.mpg.de/software/fsl/currentversion.ubuntu-xenial-amd64/ubuntu-xenial-amd64/bin:/bin:/sbin:/opt/bin:/usr/bin:/usr/sbin:/afs/cbs.mpg.de/software/scripts:/afs/cbs.mpg.de/software/scripts/science:/afs/cbs.mpg.de/software/bin/linux:/usr/games:/home/raid2/mihai/Software/doublecmd/:/home/raid2/mihai/Software/pycharm-community-2016.1.2/bin/:~/Software/scripts/:/home/raid2/mihai/Software/doublecmd/:/home/raid2/mihai/Software/pycharm-community-2016.1.2/bin/:~/Software/scripts/
* PERL5LIB : /afs/cbs.mpg.de/software/perllib
* PS1 : spm=12.6685_\u@\h:\w > 
* PWD : /nobackup/archimedes1/Glad/Projects/Top-down_mod_MGB/Experiments/TdMGB_fMRI/DATA/code/analysis_pipeline_nypipe
* SHELL : /bin/bash
* SHINTERACTIVE : 1
* SHLVL : 2
* SHTERM : 1
* SSH_CLIENT : 10.0.64.131 45992 22
* SSH_CONNECTION : 10.0.64.131 45992 10.0.66.236 22
* SSH_TTY : /dev/pts/3
* TERM : xterm
* USER : mihai
* XDG_SESSION_COOKIE : 704422f010174212a82cce3e9150bb4d-1484126805.61868-1306621854
* _ : /nobackup/archimedes1/Glad/anaconda2_serverwide/bin/ipython
* dir : /afs/cbs.mpg.de/software/spm/12.6685

@Glad

If you specify all your conds with a ‘/’ at the end, then you shouldn’t run into this. basically, it is finding the _cond_1 substitution in _cond_11 and doing that first. The trailing slash will ensure the substitution happens to the correct number. I would also add the trailing ‘/’ at the end of your substitutions so the path doesn’t get affected

2 Likes

We hit this exact problem this week, thanks for the solution.