Skip to content

Commit

Permalink
[ENH] Begin adding stim_file option to Events (task events)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Levitas committed Aug 16, 2023
1 parent cc0a2ee commit b7f6171
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 11 deletions.
7 changes: 6 additions & 1 deletion handler/convert.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions handler/convert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down
5 changes: 3 additions & 2 deletions handler/ezBIDS_core/ezBIDS_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
]

Expand Down Expand Up @@ -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": {},
Expand Down
12 changes: 12 additions & 0 deletions ui/src/Events.vue
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,18 @@
</td>
</tr>

<tr>
<th>stim_file</th>
<td>
<columnSelecter v-model="columns.stim_file" :columnKeys="ezbids.columnKeys" :sampleValues="events.sampleValues"/>

<p>
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 <a href="https://bids-specification.readthedocs.io/en/stable/99-appendices/03-hed.html">BIDS Specification / Appendix 3</a>
</p>
<br>
</td>
</tr>

</table>

<!--
Expand Down
1 change: 1 addition & 0 deletions ui/src/Objects.vue
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@
<el-table-column v-if="item.eventsBIDS[0].response_time" prop="response_time" label="response_time" />
<el-table-column v-if="item.eventsBIDS[0].value" prop="value" label="value" />
<el-table-column v-if="item.eventsBIDS[0].HED" prop="HED" label="HED" />
<el-table-column v-if="item.eventsBIDS[0].stim_file" prop="stim_file" label="stim_file" />
</el-table>
</el-form-item>
<br>
Expand Down
1 change: 1 addition & 0 deletions ui/src/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ export function createEventsTSV(ezbids : IEzbids, events : IEvents) {
if(events.columns.trialType) rec.trial_type = event[events.columns.trialType];
if(events.columns.value) rec.value = event[events.columns.value];
if(events.columns.HED) rec.HED = event[events.columns.HED];
if(events.columns.stim_file) rec.stim_file = event[events.columns.stim_file];

(item.eventsBIDS as IBIDSEvent[]).push(rec);

Expand Down
4 changes: 3 additions & 1 deletion ui/src/libUnsafe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1045,7 +1045,9 @@ export function mapEventColumns(ezbids_events, events) {

values: null,

HED: null
HED: null,

stim_file: null
}
}
}
28 changes: 21 additions & 7 deletions ui/src/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,23 @@ import {
// export type GenericSchema = { [key: string]: GenericRule | GenericSchema }
// export type SchemaTypeLike = AnyOf | SchemaType

export interface ContainerObject {
Type: string;
Tag: string;
}

export interface DatasetDescriptionObject {
Name: string,
Version: string,
Description: string,
CodeURL: string,
export interface GeneratedByObject {
Name: string;
Version: string;
Description: string;
CodeURL: string;
Container: [ContainerObject];
}

export interface SourceDatasetObject {
DOI: string;
URL: string;
Version: string;
}

export interface DatasetDescription {
Expand All @@ -80,8 +91,8 @@ export interface DatasetDescription {
EthicsApprovals: string[];
ReferencesAndLinks: string[];
DatasetDOI: string;
GeneratedBy: [DatasetDescriptionObject];
SourceDatasets: string[];
GeneratedBy: [GeneratedByObject];
SourceDatasets: [SourceDatasetObject];
}

export interface PatientInfo {
Expand Down Expand Up @@ -141,6 +152,7 @@ export interface IBIDSEvent {
response_time?: number;
value?: string|number;
HED?: string;
stim_file?: string;
}

export interface IObjectItem {
Expand Down Expand Up @@ -356,6 +368,8 @@ const state = {
value: null,

HED: null,

stim_file: null,
},

trialTypes: {
Expand Down

1 comment on commit b7f6171

@dlevitas
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, bids-validator will fail because we don't enable stimulus file to be uploaded. Will work on that, but for now that validator error can be ignored.

Please sign in to comment.