bbfrederick/rapidtide

Including column number for cardiacfile takes respiratory signal instead of cardiac in happy V2.0alpha12

Closed this issue · 1 comments

Describe the bug
I'm using the happy function using the fredericklab/rapidtide_dev:v2.0alpha12 version. I have physlog.json file that contains three columns of {'cardiac','respiratory','triggers'}. When using the --cardiacfile argument in format of .json/tsv, specifying the column number to 1 in order to use the 'cardiac' signal, it takes the 'respiratory' signal in column 2 instead.

To Reproduce

Run docker image : fredericklab/rapidtide_dev:v2.0alpha12

docker run \
    --volume=INPUTDIRECTORY:/data_in,OUTPUTDIRECTORY:/data_out \
    fredericklab/rapidtide_dev:v2.0alpha12 \
        happy \
            /data_in/YOURNIFTIFILE.nii.gz \
            /data_in/SLICE_TIMING.txt \
            /data_out/outputname \
           --cardiacfile=/data_in/MYFILE_physio.json:1 \
           --debug

The pleth_fullres information from using the extra --debug argument shows the respiratory signal being taken instead of the cardiac signal from the .tsv file.

Expected behavior
Expected the 'cardiac' signal to be taken instead of the 'respiratory'.

Possible solution
It seems to be that specifying the column number to 1 for the --cardiacfile argument takes the second column (respiratory) of the .tsv, and 2 the third column (triggers) of the .tsv.

Specifying 0 or 3 will give an error as per the code in the function readcolfrombidstsv :

specified column number 0 is out of range in /input/sub-08_task-rest_run-MB6_physio.json
specified column number 3 is out of range in /input/sub-08_task-rest_run-MB6_physio.json

Changing the range of allowed column numbers in the function readcolfrombidstsv might solve the problem :

 # we can only get here if columnname is undefined
        if not (0 < columnnum < len(columns)):
            print(
                "specified column number",
                columnnum,
                "is out of range in",
                inputfilename,
            )
            return None, None, None
        else:
            return samplerate, starttime, data[columnnum, :]

Changing columnnum to be allowed to take the value of 0 (e.g. if not (columnnum<len(columns)) : will allow to take the 'cardiac signal' when specifying 0 for column number in --cardiacfile instead of taking the second column when 1 is specified (respiratory signal).
Not sure if this would break anything else in the program, as this might be intended behaviour.

Desktop (please complete the following information):
Desktop Linux ubuntu 16.04 running docker version rapidtide_dev:v2.0alpha12

Additional context
I uploaded the used .json/tsv file here that gave me the behaviour mentioned in this issue.
physio_json.zip

Closing as the mentioned issue is fixed.