-
Notifications
You must be signed in to change notification settings - Fork 173
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
[New Feature] SQL Patch and functionality for EEG BIDS Derivatives #7345
[New Feature] SQL Patch and functionality for EEG BIDS Derivatives #7345
Conversation
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.
@AlexandraLivadas LGTM. See minor comments attached to the review.
CREATE TABLE `annotation_instance` ( | ||
`AnnotationInstanceID` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, | ||
`AnnotationFileID` INT(10) UNSIGNED NOT NULL, | ||
`ParameterFileID` INT(10) UNSIGNED NOT NULL, |
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.
`ParameterFileID` INT(10) UNSIGNED NOT NULL, | |
`AnnotationParameterID` INT(10) UNSIGNED NOT NULL, |
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.
keep the same column name as in the table annotation_instance.
`AbsoluteTime` TIMESTAMP, | ||
`Description` VARCHAR(255), | ||
PRIMARY KEY (`AnnotationInstanceID`), | ||
CONSTRAINT `FK_parameter_file_ID` |
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.
CONSTRAINT `FK_parameter_file_ID` | |
CONSTRAINT `FK_annotation_parameter_ID` |
`Description` VARCHAR(255), | ||
PRIMARY KEY (`AnnotationInstanceID`), | ||
CONSTRAINT `FK_parameter_file_ID` | ||
FOREIGN KEY (`ParameterFileID`) |
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.
FOREIGN KEY (`ParameterFileID`) | |
FOREIGN KEY (`AnnotationParameterID`) |
REFERENCES `physiological_file` (`PhysiologicalFileID`), | ||
CONSTRAINT `FK_annotation_file_type` | ||
FOREIGN KEY (`FileType`) | ||
REFERENCES `annotation_file_type` (`Type`) |
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.
REFERENCES `annotation_file_type` (`Type`) | |
REFERENCES `annotation_file_type` (`FileType`) |
|
||
-- Create annotation_file_type table | ||
CREATE TABLE `annotation_file_type` ( | ||
`Type` VARCHAR(20) NOT NULL UNIQUE, |
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.
`Type` VARCHAR(20) NOT NULL UNIQUE, | |
`FileType` VARCHAR(20) NOT NULL UNIQUE, |
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.
to be consistent with the FK in subsequent table
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.
LGTM
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.
Great additions Alex !
- 1 change requested on the "session" page : "Annotation Files" button rename and meove below events.
- main module page: tweak the filter language and order, and also use the Links column to show when there is derived data (no new column needed)
modules/electrophysiology_browser/jsx/components/electrophysiology_session_panels.js
Outdated
Show resolved
Hide resolved
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.
Hi Alex, thanks for these updates! it's coming along nicely
I've spotted a few more things to bring into better alignment with how 'Events' fields are consistently named.
Quick question for you and also @cmadjar 's input --:
-
Could these schema changes go in with the electrophysiology tables instead of a new schema file? (
0000...6-Derivatives.sql
) These tables include EEG field names hardcoded likePhysiology_file_id
, orchannel
inannotation_instance
table. -
Because they're presently very EEG-specific, I think it's better to name the tables as the Events tables are named: e.g.
physiological_annotation_file
instead ofannotation_file
?
Remind me, was this considered?
Additional comments / tiny changes included inline below, please review.
type: 'select', | ||
options: { | ||
Raw: 'Raw', | ||
Derivatives: 'Derivatives', |
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.
Derivatives: 'Derivatives', | |
Derivative: 'Derivative', |
@@ -0,0 +1,117 @@ | |||
-- SQL tables for BIDS derivative file structure |
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.
filename should change to ...electrophysiology_annotation_tables
@@ -30,6 +30,7 @@ class FilePanel extends Component { | |||
'download_electrode_info', | |||
'download_channels_info', | |||
'download_events', | |||
'download_annotation_files', |
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.
to match events:
'download_annotation_files', | |
'download_annotations', |
target='_blank' | ||
download={this.state.data.downloads[0].file} | ||
> | ||
<button id='btn_download_annotation_files' |
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.
<button id='btn_download_annotation_files' | |
<button id='btn_download_annotations' |
see above
style={stylesFile.div.element.download_title} | ||
>Annotations</div> | ||
<div className={'col-xs-2'}> | ||
<a id='download_annotation_files' |
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.
<a id='download_annotation_files' | |
<a id='download_annotations' |
update to match
modules/electrophysiology_browser/jsx/electrophysiologyBrowserIndex.js
Outdated
Show resolved
Hide resolved
modules/electrophysiology_browser/jsx/electrophysiologySessionView.js
Outdated
Show resolved
Hide resolved
@@ -268,7 +268,8 @@ function testEEGBrowserWithSitePermissions() | |||
*/ | |||
function testFilters() | |||
{ | |||
$this->safeGet($this->url . "/electrophysiology_browser/"); | |||
$this->markTestSkipped('Must be updated with annotation additions to pass'); |
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.
$this->markTestSkipped('Must be updated with annotation additions to pass'); | |
$this->markTestSkipped('Must be updated with annotations to pass'); |
is this suggestion here more accurate?
@@ -342,6 +343,7 @@ function testFilters() | |||
*/ | |||
function testEEGBrowserSortableByColumn() | |||
{ | |||
$this->markTestSkipped('Must be updated with annotation additions to pass'); |
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.
same : "annotations" is perhaps clearer than "annotation additions" ?
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.
more instances of the same below...
@christinerogers To respond to your latest comments/requested changes, I think putting the SQL changes in the same schema as the EEG (physiological) tables does make sense in this case. You're right that these tables are only related to physiological files and cannot be applied to other types of files or modules, so it makes sense to rename the tables to make that relation clearer. I've made the requested changes :) |
s.ID AS SessionID, | ||
s.CenterID AS CenterID, | ||
s.ProjectID AS ProjectID | ||
s.ProjectID AS ProjectID |
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.
Unnecessary white spaces
@@ -47,10 +47,17 @@ class ElectrophysiologyBrowserRowProvisioner | |||
s.Visit_label AS Visit_Label, | |||
MIN(pf.AcquisitionTime) AS Acquisition_Time, | |||
MIN(pf.InsertTime) AS Insert_Time, | |||
GROUP_CONCAT(DISTINCT pot.OutputTypeName) AS Links, | |||
GROUP_CONCAT(DISTINCT CASE | |||
WHEN pot.OutputTypeName='derivatives' THEN 'raw,derivative' |
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.
Should be WHEN pot.OutputTypeName='derivatives' THEN 'raw,derivatives'
otherwise the type is unrecognized (sessions.inc.class only accept raw and derivatives as valid types).
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.
Christine requested that I change all "derivatives" to singular. Is it alright if I change sessions.class.inc to take "raw" or "derivative" as valid output types instead to match?
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.
I tend to think that renaming the fields in the query is prone to mistakes as it introduces mismatches between the backend/frontend and the database naming convention. Ideally, the database entry should match but I don't know if changing it at this point is a good idea.
ELSE 'raw' | ||
END) AS Links, | ||
GROUP_CONCAT(DISTINCT CASE | ||
WHEN pot.OutputTypeName='derivatives' THEN 'Derivative' |
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.
Should be WHEN pot.OutputTypeName='derivatives' THEN 'Derivatives' to be consistent with the row entries (since the recommended change above).
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.
If you look at Christine's requested changes above, she requested that I change all mentions of "Derivatives" to singular and not plural
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.
Therefore the sessions class needs an update (and ideally the database entry: SQL/0000-00-05-ElectrophysiologyTables.sql).
name: 'type', | ||
type: 'select', | ||
options: { | ||
Raw: 'Raw', |
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.
Might be more flexible to pass the options as props to stay consistent with the database state. (see how this is done for Site, Project). That way, if a new element is added in the table physiological_output_type, it will automatically be added in the filter.
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.
Good point!
GROUP_CONCAT(DISTINCT pot.OutputTypeName) AS Links, | ||
GROUP_CONCAT(DISTINCT CASE | ||
WHEN pot.OutputTypeName='derivatives' THEN 'raw,derivative' | ||
ELSE 'raw' |
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.
This works until a new type is added in OutputTypeName. It will fall in the else case and be assigned to 'raw'.
It's safer to change for ELSE pot.OutputTypeName
END) AS Links, | ||
GROUP_CONCAT(DISTINCT CASE | ||
WHEN pot.OutputTypeName='derivatives' THEN 'Derivative' | ||
ELSE 'Raw' |
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.
Same comment here... this works until a new type is added in OutputTypeName. It will fall in the else case and be assigned to 'Raw'.
@@ -47,10 +47,17 @@ class ElectrophysiologyBrowserRowProvisioner | |||
s.Visit_label AS Visit_Label, | |||
MIN(pf.AcquisitionTime) AS Acquisition_Time, | |||
MIN(pf.InsertTime) AS Insert_Time, | |||
GROUP_CONCAT(DISTINCT pot.OutputTypeName) AS Links, |
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.
The GROUP_CONCAT/DISTINCT combo prevents duplicates entries when a session contains multiple files of the same type (ex: 2 raw files will display only one raw link in the data table). For 2 files of mixed type, it will display raw twice in the links in the data table (since ''raw", and ''raw,derivative" are distinct).
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.
This issue has been resolved in the latest commit, and the picture in the PR description has been updated to show the new view!
I noticed the filter Type stopped working for entries containing multiple files: { |
@AlexandraLivadas how are you doing with these comments? Stuck anywhere? |
|
||
-- Create annotation_archive which will store archives of all the annotation files for | ||
-- Front-end download | ||
CREATE TABLE `physiological_annotation_archive` ( |
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.
TO DISCUSS - If the annotations need to be synchronized with user inputs, this table should maybe be deleted and the zip created on the fly when download is requested.
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.
This is a good point. This is the way that the pysiological files are handled in general, which is why I implemented it this way. You're right though that in this case, it does not make sense.
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.
For now, let's follow the example of the .tgz created by the pipeline specifically as a downloadable package.
e.g. bids_imports/Face13_BIDSVersion_1.1.0/sub-OTT166/ses-V1/eeg/sub-OTT166_ses-V1_task-faceO_eeg.tgz
Basically the archive for annotations should be created/structured similarly.
Agreed this should be revisited and discussed when we come to adding/editing annotations in the module - e.g. are all .tgz updated?
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.
Ok in that case I will leave this table in, as that is how it's structured for the physiological tables/files.
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.
nice work, @AlexandraLivadas
@driusan Could you please final review?
It's blocking another time-sensitive PR, thanks.
@AlexandraLivadas |
316cbb1
to
95fcf5d
Compare
@driusan The PR is now passing the tests. |
Thanks @AlexandraLivadas and @laemtl @driusan if you have time - thanks for looking at it when you can, this is blocking a few other PRs which are important for a mid-May grant deliverable. |
Re-enable and fix skipped tests in PR #7345.
…ces#7345) This contains an SQL patch to create new tables for the annotation features that will be added in the Electrophysiology Browser module. It also includes basic functionalities in the EEG Browser to support these derivatives, including a filter in the main menu and a download option for annotation files.
Re-enable and fix skipped tests in PR aces#7345.
This PR contains an SQL patch to create new tables for the annotation features that will be added in the Electrophysiology Browser module. This PR also includes basic functionalities in the EEG Browser to support these derivatives, including a filter in the main menu and a download option for annotation files.
To test this change
a. Note that in order to test the filter, data will need to be added to the annotation_file table
a. Note again that in order to test this button, data must be added to the annotation_file and annotation_archive tables. If needed, I can add a patch that will add data to these tables but this patch should be deleted before the PR is merged
Main Menu with Filter:
Sessions page with download annotations: