incf-nidash / PyNIDM

Other
21 stars 31 forks source link

csv2nidm: read tsvs by default #259

Closed jdkent closed 3 years ago

jdkent commented 3 years ago

I tried running csv2nidm on this tsv file and got the following output:

Variable participant_id age     sex     handedness automatically mapped to participant/subject idenfier
Label: participant_id   age     sex     handedness
Description: subject/participant identifier
Source Variable: participant_id age     sex     handedness
---------------------------------------------------------------------------------------
Creating NIDM file...
1: participant_id       age     sex     handedness
Please select the subject ID field from the list above:

which is not what I want (it's representing all column headers as a single column), but when I converted the file to a csv, csv2nidm worked as expected. According to the bids specification, phenotypic data should be represented as a tsv, so I think the default behavior of csv2nidm should handle a tsv.

To change this behavior, I believe all that is needed is changing this line https://github.com/incf-nidash/PyNIDM/blob/2f48a8b6b7f72cd01ae65cc88f454c35cb68d587/nidm/experiment/tools/csv2nidm.py#L104

to:

 df = pd.read_csv(args.csv_file, sep='\t')

or maybe some additional logic to try to guess the appropriate separator (or add a command-line option), Depending on how important it is to not make backward-incompatible changes.

dbkeator commented 3 years ago

This is fixed in release v3.7.4. Thanks!