Skip to main content

A helper package containing BIDS directory monitor module

Project description

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

$ 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

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

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tvb-bids-monitor-2.7.1.tar.gz (41.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tvb_bids_monitor-2.7.1-py3-none-any.whl (57.0 kB view details)

Uploaded Python 3

File details

Details for the file tvb-bids-monitor-2.7.1.tar.gz.

File metadata

  • Download URL: tvb-bids-monitor-2.7.1.tar.gz
  • Upload date:
  • Size: 41.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.12

File hashes

Hashes for tvb-bids-monitor-2.7.1.tar.gz
Algorithm Hash digest
SHA256 1c74d19c569f341b365e39d444467b3006719528bf1f47cf83b33469d0be8ba5
MD5 46b313ba100e1ec4011051b73b6a2bf3
BLAKE2b-256 27eaa31743aff6e8d322a9823c28f7650ff7db0d895d8379ca8a18d0a44ab21f

See more details on using hashes here.

File details

Details for the file tvb_bids_monitor-2.7.1-py3-none-any.whl.

File metadata

File hashes

Hashes for tvb_bids_monitor-2.7.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c509c8a70c82b1c9893d059e46c58958bea36ca13b3a697b658690d34f678a54
MD5 17d15d7abf6b430606499728851a1235
BLAKE2b-256 e9b52979648c08abf53b6d954ac10d9ed3aa5fbf31d71dc00d5764a79978c965

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page