Create converters
module and prototype converter for Aeon Bonsai (Sumiya)
#534
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR begins to add structure for converter for non-NeuroBlueprint formats into NeuroBlueprint, and adds a converter for Bonsai Aeon format that Sumiya is using.
The idea is to create something general and customizable, that we can also extend to have 'default' converters (e.g. from ONE). For writing customizable converters, the (suggested, not currently fixed) approach is to have a format where the converter must be in a python file and be called
convterer_func(project)
which takes the datashuttle project. Then the writer can search the project for files to converter, create the folders and do the conversion.This can be trick in some cases because we want to handle a project that is part NeuroBlueprint, part non-NeuroBlueprint. In this case, data is collected in Aeon bonsai. We want to convert it to NeuroBlueprint, then transfer it. The next day, more data will be written in Aeon Bonsai format for conversion. So the converter needs to be able to determine whether the recent Aeon Bonsai file belongs to an existing subject or not (if it does, then the session must be added to this existing subject).
A new function
get_sub_names_from_key_value_pair
is introduced for this, and can be used alongside the existingproject.get_next_sub()
andproject.get_next_ses()
.The workflow is to call
project.convert(path_to_module)
. The function will load the passed module, and run theconverter_func()
function. It will also initialise logging, and within the conveter function the user can log withproject.log_and_message()
orproject.log_and_raise_error()
which are now exposed on the datashuttle class.Testing this PR
This PR is still in a prototyping phase. Sumiya if you'd like to test this out, you can run the
datashuttle/converters/run_convert_sumiya.py
script and it will try and convert any folders in/datashuttle/converters/example_project
.The main script that does the conversion and is passed to
project.convert()
is/datashuttle/converters/convert_sumiya.py
. Just to play around you can run this directly.However, feel free to move it and we can work on it elsewhere e.g. on
vr-abcd
, whatever is most convenient. Eventually on the datashuttle side, we will probably expose only theproject.convert()
function to allow any user to insert their convter of choice (and down the line provide only a few default converters e.g. to/from BIDS. Otherwise if it's easier, we can use this PR for prototype and test the Aeon converter function and remove it right at the end.TODO