cwatson / brainGraph

Graph theory analysis of brain MRI data
173 stars 51 forks source link

numeric subject IDs with leading zeros #13

Closed AndrewLawrence closed 5 years ago

AndrewLawrence commented 5 years ago

This is an edge case, but where all subject IDs are numeric then those with leading zeros will be changed when imported with import_scn.

For example "0506" becomes "506" because fread guesses whether columns are numeric or not based on their content. Character output is guaranteed because of as.character, but if there are leading zeros then as.character(as.numeric(x)) != as.character(x).

I have a relatively simple fix, so simple I've not bothered with a PR - happy to do so if it helps. If you add the argument colClasses=list(character = 1) to the calls to fread (within update_fs_names) then column 1 will always be read in as a character by data.table.

This should have no side effects as types for all other columns will be unaffected and column 1 is specified to be the freesurfer Study.ID

cwatson commented 5 years ago

Thanks for discovering this, it does look like the fix is that simple. I will push it over the weekend.

AndrewLawrence commented 5 years ago

Great, thanks! - and thanks for putting such a great package out there.