-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add trials metadata #999
base: main
Are you sure you want to change the base?
Add trials metadata #999
Changes from all commits
a4e4439
22d6aff
1b8012f
e6ecf69
214243b
4576bc4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
{ | ||
"type": "object", | ||
"patternProperties": { | ||
"^[a-zA-Z0-9_]+$": { | ||
"type": "object", | ||
"properties": { | ||
"description": { | ||
"type": "string" | ||
}, | ||
"columns": { | ||
"type": "array", | ||
"items": { | ||
"type": "object", | ||
"properties": { | ||
"name": { | ||
"type": "string" | ||
}, | ||
"description": { | ||
"type": "string" | ||
} | ||
}, | ||
"required": [ | ||
"name" | ||
], | ||
"additionalProperties": false | ||
} | ||
}, | ||
"data": { | ||
"type": "array", | ||
"items": { | ||
"type": "object", | ||
"properties": { | ||
"start_time": { | ||
"type": "number" | ||
}, | ||
"stop_time": { | ||
"type": "number" | ||
} | ||
}, | ||
"required": [ | ||
"start_time", | ||
"stop_time" | ||
], | ||
"additionalProperties": true | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
from neuroconv.datainterfaces import ( | ||
CsvTimeIntervalsInterface, | ||
ExcelTimeIntervalsInterface, | ||
TimeIntervalsInterface, | ||
) | ||
from neuroconv.tools.nwb_helpers import make_nwbfile_from_metadata | ||
from neuroconv.tools.text import convert_df_to_time_intervals | ||
|
@@ -96,3 +97,40 @@ def test_csv_round_trip_rename(tmp_path): | |
def test_get_metadata_schema(): | ||
interface = CsvTimeIntervalsInterface(trials_csv_path) | ||
interface.get_metadata_schema() | ||
|
||
|
||
def test_trials(): | ||
metadata = dict( | ||
NWBFile=dict( | ||
session_start_time=datetime.now().astimezone(), | ||
), | ||
TimeIntervals=dict( | ||
trials=dict( | ||
columns=dict( | ||
start_time=dict(description="start time of the trial"), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't this overwritten by the schema by default? the description of start_time and stop_time? |
||
stop_time=dict(description="stop time of the trial"), | ||
correct=dict(description="correct or not"), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was expecting that you had to pass the name inside the dictionary as well from reading the schema, but here, the name here is only passed as the dictionary key. |
||
), | ||
data=[ | ||
dict(start_time=0.0, stop_time=1.0, correct=True), | ||
dict(start_time=1.0, stop_time=2.0, correct=False), | ||
], | ||
), | ||
new_table=dict( | ||
columns=dict( | ||
stim_id=dict(description="stimulus ID"), | ||
), | ||
data=[ | ||
dict(start_time=0.0, stop_time=1.0, stim_id=0), | ||
dict(start_time=1.0, stop_time=2.0, stim_id=1), | ||
], | ||
), | ||
), | ||
) | ||
|
||
nwbfile = TimeIntervalsInterface().create_nwbfile(metadata) | ||
assert nwbfile.trials.correct.description == "correct or not" | ||
assert_array_equal(nwbfile.trials.correct[:], [True, False]) | ||
assert_array_equal(nwbfile.trials.start_time[:], [0.0, 1.0]) | ||
|
||
assert_array_equal(nwbfile.intervals["new_table"].stim_id[:], [0, 1]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't description be required as well?]
Throws an error.