From b7f6171a7d7667eff2a6e9ec8129543dd1011fe8 Mon Sep 17 00:00:00 2001 From: Dan Levitas Date: Wed, 16 Aug 2023 15:59:02 +0000 Subject: [PATCH] [ENH] Begin adding stim_file option to Events (task events) --- handler/convert.js | 7 ++++++- handler/convert.ts | 5 +++++ handler/ezBIDS_core/ezBIDS_core.py | 5 +++-- ui/src/Events.vue | 12 ++++++++++++ ui/src/Objects.vue | 1 + ui/src/lib.ts | 1 + ui/src/libUnsafe.ts | 4 +++- ui/src/store/index.ts | 28 +++++++++++++++++++++------- 8 files changed, 52 insertions(+), 11 deletions(-) diff --git a/handler/convert.js b/handler/convert.js index 6237ccc6..0adaef48 100755 --- a/handler/convert.js +++ b/handler/convert.js @@ -213,11 +213,16 @@ async.forEachOf(info.objects, (o, idx, next_o) => { const headers = Object.keys(events.eventsBIDS[0]); //take first index value to see which columns user selected events.content = headers.join("\t") + "\n"; events.eventsBIDS.forEach(rec => { + if(rec.stim_file) { + if(!rec.stim_file.startsWith("/stimuli/")) { + rec.stim_file = "/stimuli/" + rec.stim_file + } + } const row = []; headers.forEach(key => { row.push(rec[key]); }); - events.content += row.join("\t") + "\n"; + events.content += row.join("\t") + "\n"; }); //add stuff to sidecar const sidecar = o.items.find(o => o.name == "json"); diff --git a/handler/convert.ts b/handler/convert.ts index 48fa82a2..6b83d23a 100755 --- a/handler/convert.ts +++ b/handler/convert.ts @@ -233,6 +233,11 @@ async.forEachOf(info.objects, (o, idx, next_o)=>{ const headers = Object.keys(events.eventsBIDS[0]) //take first index value to see which columns user selected events.content = headers.join("\t")+"\n"; events.eventsBIDS.forEach(rec=>{ + if(rec.stim_file) { + if(!rec.stim_file.startsWith("/stimuli/")) { + rec.stim_file = "/stimuli/" + rec.stim_file + } + } const row = []; headers.forEach(key=>{ row.push(rec[key]); diff --git a/handler/ezBIDS_core/ezBIDS_core.py b/handler/ezBIDS_core/ezBIDS_core.py index 4f39e354..5e6e92ac 100755 --- a/handler/ezBIDS_core/ezBIDS_core.py +++ b/handler/ezBIDS_core/ezBIDS_core.py @@ -254,7 +254,7 @@ def generate_dataset_description(DATA_DIR, bids_compliant): { "DOI": "n/a", "URL": "https://brainlife.io/ezbids/", - "Version": "n/a" + "Version": "1.0.0" } ] @@ -2430,7 +2430,8 @@ def extract_series_info(dataset_list_unique_series): "responseTime2": None, "responseTimeUnit": "sec", "values": None, - "HED": None + "HED": None, + "stim_file": None }, "loaded": False, "sampleValues": {}, diff --git a/ui/src/Events.vue b/ui/src/Events.vue index a7758e71..e4824d0f 100755 --- a/ui/src/Events.vue +++ b/ui/src/Events.vue @@ -203,6 +203,18 @@ + + stim_file + + + +

+ Represents the location of the stimulus file (such as an image, video, or audio file) presented at the given onset time. There are no restrictions on the file formats of the stimuli files, but they should be stored in the /stimuli directory (under the root directory of the dataset; with OPTIONAL subdirectories). The values under the stim_file column correspond to a path relative to /stimuli. For example images/cat03.jpg will be translated to /stimuli/images/cat03.jpg. See BIDS Specification / Appendix 3 +

+
+ + +