[BUG]: subject ID truncated incorrectly in condor submit dag file #322
Labels
No labels
CRITICAL
Stale
WIP
bug
concept
coordinate
dataset
dependencies
documentation
duplicate
enhancement
github_actions
good first issue
help wanted
invalid
maintenance
maps
marker
mask
on hold
parcellation
preprocess
question
ready
storage
template-space
triage
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
juaml/junifer!322
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/subject-id-truncation"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Is there an existing issue for this?
Current Behavior
First I queued using the datagrabber without specifying the elements. The resulting file gives elements such as "0001" etc.
When I supply a txt file with a subset of elements I want to process, the subject ID's have the 0 buffers removed.
Expected Behavior
It should output the ID's as a string so the buffering 0's should still be there.
Steps To Reproduce
I then run
junifer queue test.yaml --element elements.txtI tried this with and without quotes but both result in the wrong output (snippet from the result dag file):
I then run the
junifer queue aomic_id1000.yamlto see what the file should look like, here the result looks as follows (only a snippet):Environment
Relevant log output
No response
Anything else?
No response
We are using only strings for replacements for AOMIC instead of "sub-0001". I was having that problem yesterday, as the numbers were converted to ints.
I know that maybe this is not the place, but we should try to keep with the BIDS standard and use the subjects with the prefix.
I want to merge the junifer DF with the participants.tsv and I need to manipulate the index.
So for this bug, the parse elements should not convert from text to int. But how can we know when it's ok to do it? or when it's not?
the elements should always be string literals in my opinion. Maybe that requires changing some data grabber implementations? but that is in my opinion the easiest and best solution
Not at all. I think it's the element parser that should not convert to int. Indeed you can see here that some of this things is converting to int. Even though we specifically want strings.
github.com/juaml/junifer@a9e799caa3/junifer/api/cli.py (L98-L124)Yeah it should never do that in my opinion. I would always expect that the elements in the text files are seen as strings.
Following the BIDS standard and having
sub-prefix in my opinion is also the best way. The way pandas.DataFrames handles data loading from CSV is kind of the issue here. Although, the code is meant to convert as much as possible to str, it misses this and we get this issue.maybe https://numpy.org/doc/1.18/reference/generated/numpy.loadtxt.html is better suited in this case since you can specify a delimiter and tell it the dtype=str so then it should all be loaded as str
Here's a relevant issue:
https://stackoverflow.com/questions/16988526/pandas-reading-csv-as-string-type
The pandas type sniffer is the culprit from what I understand.
Also I agree with the BIDS standard thing, but still think the bug is relevant since not all datasets follow the BIDS standard (e.g. HCP also uses integers only as subject index, although the bug likely wont happen there for different reasons). So i think getting as much "type safety" as possible here will be good nonetheless
yes, i think np.loadtxt will be better here as far as i understand
We need to also be able to read elements as tuples, so basically, CSV files too
np.loadtxt can do that, it has a delimiter parameter and reads in columns to have 2D arrays of a particular type as far as i know
might be worth testing out
Okay I tested
np.loadtxtand it works correctly, will make a quick PR out of this.Okay my bad, I overlooked the pandas version which we support, so I got it working with minimal change and using pandas. I would not want to change a lot just to not have unexpected changes before a release.
makes sense, if there is a way to make it work with pandas, then thats preferred i think
@LeSasse @fraimondo can you run your YAMLs with this branch and see if it works as expected?
works for me now
Codecov Report
All modified and coverable lines are covered by tests ✅
Additional details and impacted files
100.00% <ø> (ø)Flags with carried forward coverage won't be shown. Click here to find out more.