neuroinformatics-unit / datashuttle

Tool for the creation, validation and transfer of neuroscience project folders.
https://datashuttle.neuroinformatics.dev/
BSD 3-Clause "New" or "Revised" License
14 stars 3 forks source link

Allow tags in name template regexp. #404

Closed JoeZiminski closed 3 months ago

JoeZiminski commented 3 months ago

This PR improves the way name templates handle tags. Previously, if a tag was used in a name template when it was compared against the formatted subject or session name it would fail e.g.

project.make_folders("rawdata", "sub-001_@DATE@") with the name template sub-\d\d\d_@DATE@ will fail as it will compare sub-001_date-<some_date> to sub-\d\d\d_@DATE@. The solution here is to also pre-format the name templates to their regexp equivalent e.g. sub-\d\d\d_@DATE@ -> sub-\d\d\d_date-\d\d\d\d\d\d\d\d.

This reason this is implemented as it is very useful to use convenience tags in the name template as when autofilling the names in the TUI, if you could click to suggest next subject you would get sub-001_@DATE@ which you can immediately click to create the folder. Previously, youd have to use date-\d\d\d\d\d\d\d\d in the name template and the auto-fill would be sub-001_date-\d\d\d\d\d\d\d\d which you would have to manually replace with @DATE@.

Checklist: