User changelog
- Fixes to .tsv export
- Filenames returned by `snirf2json` now share the entities of the input file in all cases: files like `*_coordsystem.json` are given `sub-` entities only in the interest of inheritance. `*_participants.tsv` is named this way as well, which is not typical of BIDS, but will serve to help us validate between SNIRF files which should share subject information but may not.
- The entities of the input filename are reordered like so:
- `sub-<...>_ses-<...>_task_<...>_[all other entities i.e. 'acq-']_run-<...>`
Developer changelog
- Refactored `_pull_label` into `_extract_entities_from_filename` which returns dict of all entity-value pairs in a given name. Client code calls this once and then operates on the dict.
- Refactored `_make_filename` in `make_filename_prefix` which operates on entity-value dict returned by new extract function. This was possible because we are no longer worried about parsing BIDS structures to determine inheritance levels, so the original solution was unnecessary.
- `pull_fnames` no longer cares about BIDS inheritance and so just creates dict of output file names keyed by the internal identifiers i.e. 'optodes', 'sidecar' from the entities dict.
- Removed unused `_compliancy_check`. Validation code will not be included in this library.
- Renamed `info` and `subinfo` properties to `entities` where appropriate.
- Widely removed the `'-'` from keys on entities i.e. `'sub-'` -> `'sub'`
- Renamed `json_export` method on `SnirfRun` to the more accurate `export_to_dict`.
- Now dump all JSON objects to strings before packing them into the dict returned from `export_to_dict`. Do not dump the return value, which remains a dict.
- `snirf2bids` now uses `export_to_dict` to write its files. This removes redundant export code, avoiding the case where the serial output differs from the files written to disk.
- Fix to `TSV.get_all_fields` by using a `csv.writer` to serialize the table rather than a manual loop which did not work properly to generate some files (namely *_optodes.tsv)
- `snirf2bids` now places files alongside SNIRF file input.
- TODO resolve SNIRF file closing issues in IPython environments. This is not a problem with this code but if pysnirf2 is not used carefully files may be left open.