BIDS data builder and directory monitor
=======================================
This module contains helper classes which can build BIDS datasets and import them into TVB projects. Along with this, the module also provides a way to monitor a BIDS directory and build datasets accordingly when new files are added.
BIDSDataBuilder
---------------
- Class for building BIDS dataset by providing 1) a set of json files and BIDS root directory or 2) a datatype from the subject directory (e.g. net, ts, coord, spatial)
- Contains utils for finding all dependencies of a subject json file.
- Produces a zip file.
- Takes following args
- BIDS_ROOT_DIR (reqd.)- BIDS root dir from which dataset will be created
- BIDS_DATA_TO_IMPORT - Accepts BIDSImporter net, ts, coord, spatial token to build subject type specific dataset For e.g. if BIDSImporter.TS_TOKEN is provided then, it'll build a dataset containing only TS data and their dependencies
- INITIAL_JSON_FILES - A set of initial json files with which bids dataset to be built. This is used by BIDSDirWatcher
BIDSDirWatcher
--------------
- Class for monitoring a BIDS directory and also builds datasets accordingly on new files
- Runs two threads in parallel for 1) observing a directory and 2) building/importing dataset into TVB
- Importing thread runs on a fixed interval (configurable), which also acts as a buffer time when large files are added
- Contains utils for observing specific (subjects) directories changes only
- Takes following args
- DIRECTORY_TO_WATCH (reqd.)- BIDS root dir on which is to be monitored
- UPLOAD_TRIGGER_INTERVAL - Importer thread interval in seconds
- IMPORT_DATA_IN_TVB - A flag for only creating dataset and storing and not importing into TVB projects
- TVB_PROJECT_ID - ID of TVB project on which dataset is to be imported
[launch_bids_monitor.py](tvb_framework/tvb/interfaces/rest/bids_monitor/launch_bids_monitor.py) contains sample code and it also accepts command line arguments. To start monitoring a bids directory run below command
.. code-block::
$ python launch_bids_monitor.py --rest-url=http://localhost:9090 --bids-dir=user/doc/BIDS_SAMPLE
..
where `-rest-url` is the url on which TVB rest server is running and `-bids-dir` is the BIDS root directory which is to be monitored for new files. Please note that bids monitor will only trigger when files are added inside subject directories.
Build BIDS dataset for time_series
.. code-block:: python
from tvb.interfaces.rest.bids_monitor.bids_data_builder import BIDSDataBuilder
from tvb.adapters.uploaders.bids_importer import BIDSImporter
bids_data_builder = BIDSDataBuilder(BIDSImporter.TS_TOKEN, BIDS_DIR)
zip_file_location = bids_data_builder.create_dataset_subjects()
print(zip_file_location)
..
Monitor a BIDS directory for new files
.. code-block:: python
from tvb.interfaces.rest.bids_monitor.bids_dir_monitor import BIDSDirWatcher
bids_dir_watcher = BIDSDirWatcher(
DIRECTORY_TO_WATCH=BIDS_DIR,
UPLOAD_TRIGGER_INTERVAL=20,
IMPORT_DATA_IN_TVB=True
)
bids_dir_watcher.init_watcher()
..
Some implementation details
---------------------------
* The module triggers an import in TVB only for new files added to the BIDS_DIR, not for the files that already exist in the BIDS_DIR at start-up
* Files are imported by default in the first project of the user
* If the imported file has dependencies, all dependencies and the file will be imported in TVB, even if the dependencies might already exist
Acknowledgments
---------------
This project has received funding from GSOC program 2022.
Raw data
{
"_id": null,
"home_page": "http://www.thevirtualbrain.org",
"name": "tvb-bids-monitor",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "tvb rest client brain simulator neuroscience human animal neuronal dynamics models delay",
"author": "Akash Upadhyay, Paula Prodan",
"author_email": "tvb.admin@thevirtualbrain.org",
"download_url": "https://files.pythonhosted.org/packages/55/3b/118b2b13154f2ec42364430af03a0b010624449f855ae577dbfac854a362/tvb-bids-monitor-2.8.1.tar.gz",
"platform": null,
"description": "BIDS data builder and directory monitor\n=======================================\n\nThis module contains helper classes which can build BIDS datasets and import them into TVB projects. Along with this, the module also provides a way to monitor a BIDS directory and build datasets accordingly when new files are added.\n\nBIDSDataBuilder\n---------------\n\n- Class for building BIDS dataset by providing 1) a set of json files and BIDS root directory or 2) a datatype from the subject directory (e.g. net, ts, coord, spatial)\n- Contains utils for finding all dependencies of a subject json file.\n- Produces a zip file.\n- Takes following args\n - BIDS_ROOT_DIR (reqd.)- BIDS root dir from which dataset will be created\n - BIDS_DATA_TO_IMPORT - Accepts BIDSImporter net, ts, coord, spatial token to build subject type specific dataset For e.g. if BIDSImporter.TS_TOKEN is provided then, it'll build a dataset containing only TS data and their dependencies\n - INITIAL_JSON_FILES - A set of initial json files with which bids dataset to be built. This is used by BIDSDirWatcher\n\nBIDSDirWatcher\n--------------\n\n- Class for monitoring a BIDS directory and also builds datasets accordingly on new files\n- Runs two threads in parallel for 1) observing a directory and 2) building/importing dataset into TVB\n- Importing thread runs on a fixed interval (configurable), which also acts as a buffer time when large files are added\n- Contains utils for observing specific (subjects) directories changes only\n- Takes following args\n - DIRECTORY_TO_WATCH (reqd.)- BIDS root dir on which is to be monitored\n - UPLOAD_TRIGGER_INTERVAL - Importer thread interval in seconds\n - IMPORT_DATA_IN_TVB - A flag for only creating dataset and storing and not importing into TVB projects\n - TVB_PROJECT_ID - ID of TVB project on which dataset is to be imported\n\n\n[launch_bids_monitor.py](tvb_framework/tvb/interfaces/rest/bids_monitor/launch_bids_monitor.py) contains sample code and it also accepts command line arguments. To start monitoring a bids directory run below command\n\n.. code-block::\n\n $ python launch_bids_monitor.py --rest-url=http://localhost:9090 --bids-dir=user/doc/BIDS_SAMPLE\n..\n\nwhere `-rest-url` is the url on which TVB rest server is running and `-bids-dir` is the BIDS root directory which is to be monitored for new files. Please note that bids monitor will only trigger when files are added inside subject directories.\n\nBuild BIDS dataset for time_series\n\n.. code-block:: python\n\n from tvb.interfaces.rest.bids_monitor.bids_data_builder import BIDSDataBuilder\n from tvb.adapters.uploaders.bids_importer import BIDSImporter\n\n bids_data_builder = BIDSDataBuilder(BIDSImporter.TS_TOKEN, BIDS_DIR)\n zip_file_location = bids_data_builder.create_dataset_subjects()\n print(zip_file_location)\n..\n\nMonitor a BIDS directory for new files\n\n.. code-block:: python\n\n from tvb.interfaces.rest.bids_monitor.bids_dir_monitor import BIDSDirWatcher\n\n bids_dir_watcher = BIDSDirWatcher(\n DIRECTORY_TO_WATCH=BIDS_DIR,\n UPLOAD_TRIGGER_INTERVAL=20,\n IMPORT_DATA_IN_TVB=True\n )\n bids_dir_watcher.init_watcher()\n..\n\nSome implementation details\n---------------------------\n* The module triggers an import in TVB only for new files added to the BIDS_DIR, not for the files that already exist in the BIDS_DIR at start-up\n* Files are imported by default in the first project of the user\n* If the imported file has dependencies, all dependencies and the file will be imported in TVB, even if the dependencies might already exist\n\nAcknowledgments\n---------------\nThis project has received funding from GSOC program 2022.\n",
"bugtrack_url": null,
"license": "GPL-3.0-or-later",
"summary": "A helper package containing BIDS directory monitor module",
"version": "2.8.1",
"project_urls": {
"Download": "https://github.com/the-virtual-brain/tvb-root",
"Homepage": "http://www.thevirtualbrain.org"
},
"split_keywords": [
"tvb",
"rest",
"client",
"brain",
"simulator",
"neuroscience",
"human",
"animal",
"neuronal",
"dynamics",
"models",
"delay"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "0fad4a2d9936f233db5845253ed64ea240e129d5d48b10d679b46447ef40eda5",
"md5": "15b31f9c876de056c069be933fc8d015",
"sha256": "69f08de412347e08842b972b8582785197fc41fc1dcc2ea3258d69ea5add882d"
},
"downloads": -1,
"filename": "tvb_bids_monitor-2.8.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "15b31f9c876de056c069be933fc8d015",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 92051,
"upload_time": "2023-05-23T18:39:51",
"upload_time_iso_8601": "2023-05-23T18:39:51.253622Z",
"url": "https://files.pythonhosted.org/packages/0f/ad/4a2d9936f233db5845253ed64ea240e129d5d48b10d679b46447ef40eda5/tvb_bids_monitor-2.8.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "553b118b2b13154f2ec42364430af03a0b010624449f855ae577dbfac854a362",
"md5": "24512a34e66283615322504270f32843",
"sha256": "5b53a73ce1de72ad1ad291a5a724c89c39e8ad359cc72664259af0cd1cfee377"
},
"downloads": -1,
"filename": "tvb-bids-monitor-2.8.1.tar.gz",
"has_sig": false,
"md5_digest": "24512a34e66283615322504270f32843",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 42225,
"upload_time": "2023-05-23T18:40:36",
"upload_time_iso_8601": "2023-05-23T18:40:36.058883Z",
"url": "https://files.pythonhosted.org/packages/55/3b/118b2b13154f2ec42364430af03a0b010624449f855ae577dbfac854a362/tvb-bids-monitor-2.8.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-05-23 18:40:36",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "the-virtual-brain",
"github_project": "tvb-root",
"travis_ci": false,
"coveralls": true,
"github_actions": true,
"lcname": "tvb-bids-monitor"
}