Skip to content

Commit

Permalink
Merge branch 'main' into 2020-02-11-new-schedule
Browse files Browse the repository at this point in the history
  • Loading branch information
kongtiaowang authored Apr 15, 2024
2 parents b352ce0 + 23dbe45 commit 21b2b4d
Show file tree
Hide file tree
Showing 115 changed files with 27,838 additions and 22,213 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ changes in the following format: PR #1234***
- Fix examiner site display (PR #8967)
- bvl_feedback updates in real-time (PR #8966)
- DoB and DoD format respected in candidate parameters (PR #9001)
- Fix delete file in upload (PR #9181)
- Fix profile level feedback display in behavioural QC module (PR #9192)

## LORIS 25.0 (Release Date: ????-??-??)
### Core
Expand Down
229 changes: 91 additions & 138 deletions SQL/0000-00-05-ElectrophysiologyTables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ CREATE TABLE `physiological_split_file` (
-- information that accompanies the BIDS physiological dataset
CREATE TABLE `physiological_parameter_file` (
`PhysiologicalParameterFileID` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`PhysiologicalFileID` INT(10) UNSIGNED NOT NULL,
`PhysiologicalFileID` INT(10) UNSIGNED DEFAULT NULL,
`ProjectID` INT(10) UNSIGNED DEFAULT NULL,
`ParameterTypeID` INT(10) UNSIGNED NOT NULL,
`InsertTime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
`Value` TEXT,
Expand All @@ -85,7 +86,10 @@ CREATE TABLE `physiological_parameter_file` (
ON DELETE CASCADE,
CONSTRAINT `FK_param_type_ParamTypeID`
FOREIGN KEY (`ParameterTypeID`)
REFERENCES `parameter_type` (`ParameterTypeID`)
REFERENCES `parameter_type` (`ParameterTypeID`),
CONSTRAINT `FK_ppf_project_ID`
FOREIGN KEY (`ProjectID`)
REFERENCES `Project` (`ProjectID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


Expand Down Expand Up @@ -271,7 +275,8 @@ CREATE TABLE IF NOT EXISTS `physiological_coord_system_electrode_rel` (
-- Create `physiological_event_file` table
CREATE TABLE `physiological_event_file` (
`EventFileID` int(10) unsigned NOT NULL AUTO_INCREMENT,
`PhysiologicalFileID` int(10) unsigned NOT NULL,
`PhysiologicalFileID` int(10) unsigned DEFAULT NULL,
`ProjectID` int(10) unsigned DEFAULT NULL,
`FileType` varchar(20) NOT NULL,
`FilePath` varchar(255) DEFAULT NULL,
`LastUpdate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
Expand All @@ -280,7 +285,8 @@ CREATE TABLE `physiological_event_file` (
KEY `FK_physio_file_ID` (`PhysiologicalFileID`),
KEY `FK_event_file_type` (`FileType`),
CONSTRAINT `FK_event_file_type` FOREIGN KEY (`FileType`) REFERENCES `ImagingFileTypes` (`type`),
CONSTRAINT `FK_physio_file_ID` FOREIGN KEY (`PhysiologicalFileID`) REFERENCES `physiological_file` (`PhysiologicalFileID`)
CONSTRAINT `FK_physio_file_ID` FOREIGN KEY (`PhysiologicalFileID`) REFERENCES `physiological_file` (`PhysiologicalFileID`),
CONSTRAINT `FK_pef_project_ID` FOREIGN KEY (`ProjectID`) REFERENCES `Project` (`ProjectID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
;

Expand All @@ -299,9 +305,10 @@ CREATE TABLE `physiological_task_event` (
`EventType` VARCHAR(50) DEFAULT NULL,
`TrialType` VARCHAR(255) DEFAULT NULL,
`ResponseTime` TIME DEFAULT NULL,
`AssembledHED` TEXT DEFAULT NULL,
PRIMARY KEY (`PhysiologicalTaskEventID`),
KEY `FK_event_file` (`EventFileID`),
INDEX idx_pte_EventValue (`EventValue`),
INDEX idx_pte_TrialType (`TrialType`),
CONSTRAINT `FK_phys_file_FileID_4`
FOREIGN KEY (`PhysiologicalFileID`)
REFERENCES `physiological_file` (`PhysiologicalFileID`)
Expand Down Expand Up @@ -382,105 +389,6 @@ CREATE TABLE `physiological_archive` (
ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- SQL tables for BIDS derivative file structure
-- Create physiological_annotation_file_type table
CREATE TABLE `physiological_annotation_file_type` (
`FileType` VARCHAR(20) NOT NULL UNIQUE,
`Description` VARCHAR(255),
PRIMARY KEY (`FileType`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- Create physiological_annotation_file table
CREATE TABLE `physiological_annotation_file` (
`AnnotationFileID` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`PhysiologicalFileID` INT(10) UNSIGNED NOT NULL,
`FileType` VARCHAR(20) NOT NULL,
`FilePath` VARCHAR(255),
`LastUpdate` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`LastWritten` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`AnnotationFileID`),
CONSTRAINT `FK_phys_file_ID`
FOREIGN KEY (`PhysiologicalFileID`)
REFERENCES `physiological_file` (`PhysiologicalFileID`),
CONSTRAINT `FK_annotation_file_type`
FOREIGN KEY (`FileType`)
REFERENCES `physiological_annotation_file_type` (`FileType`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- Create annotation_archive which will store archives of all the annotation files for
-- Front-end download
CREATE TABLE `physiological_annotation_archive` (
`AnnotationArchiveID` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`PhysiologicalFileID` INT(10) UNSIGNED NOT NULL,
`Blake2bHash` VARCHAR(128) NOT NULL,
`FilePath` VARCHAR(255) NOT NULL,
PRIMARY KEY (`AnnotationArchiveID`),
CONSTRAINT `FK_physiological_file_ID`
FOREIGN KEY (`PhysiologicalFileID`)
REFERENCES `physiological_file` (`PhysiologicalFileID`)
ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- Create annotation_parameter table
-- Note: This corresponds with the JSON annotation files
CREATE TABLE `physiological_annotation_parameter` (
`AnnotationParameterID` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`AnnotationFileID` INT(10) UNSIGNED NOT NULL,
`Description` TEXT DEFAULT NULL,
`Sources` VARCHAR(255),
`Author` VARCHAR(255),
PRIMARY KEY (`AnnotationParameterID`),
CONSTRAINT `FK_annotation_file_ID`
FOREIGN KEY (`AnnotationFileID`)
REFERENCES `physiological_annotation_file` (`AnnotationFileID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- Create an annotation_label_type table
CREATE TABLE `physiological_annotation_label` (
`AnnotationLabelID` INT(5) UNSIGNED NOT NULL AUTO_INCREMENT,
`AnnotationFileID` INT(10) UNSIGNED DEFAULT NULL,
`LabelName` VARCHAR(255) NOT NULL,
`LabelDescription` TEXT DEFAULT NULL,
PRIMARY KEY (`AnnotationLabelID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- Create annotation_tsv table
-- Note: This corresponds with the .tsv annotation files
CREATE TABLE `physiological_annotation_instance` (
`AnnotationInstanceID` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`AnnotationFileID` INT(10) UNSIGNED NOT NULL,
`AnnotationParameterID` INT(10) UNSIGNED NOT NULL,
`Onset` DECIMAL(10, 4),
`Duration` DECIMAL(10, 4) DEFAULT 0,
`AnnotationLabelID` INT(5) UNSIGNED NOT NULL,
`Channels` TEXT,
`AbsoluteTime` TIMESTAMP,
`Description` VARCHAR(255),
PRIMARY KEY (`AnnotationInstanceID`),
CONSTRAINT `FK_annotation_parameter_ID`
FOREIGN KEY (`AnnotationParameterID`)
REFERENCES `physiological_annotation_parameter` (`AnnotationParameterID`),
CONSTRAINT `FK_annotation_file`
FOREIGN KEY (`AnnotationFileID`)
REFERENCES `physiological_annotation_file` (`AnnotationFileID`),
CONSTRAINT `FK_annotation_label_ID`
FOREIGN KEY (`AnnotationLabelID`)
REFERENCES `physiological_annotation_label` (`AnnotationLabelID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- Create physiological_annotation_rel table
CREATE TABLE `physiological_annotation_rel` (
`AnnotationTSV` INT(10) UNSIGNED NOT NULL,
`AnnotationJSON` INT(10) UNSIGNED NOT NULL,
PRIMARY KEY (`AnnotationTSV`, `AnnotationJSON`),
CONSTRAINT `FK_AnnotationTSV`
FOREIGN KEY (`AnnotationTSV`)
REFERENCES `physiological_annotation_file` (`AnnotationFileID`),
CONSTRAINT `FK_AnnotationJSON`
FOREIGN KEY (`AnnotationJSON`)
REFERENCES `physiological_annotation_file` (`AnnotationFileID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- Create EEG upload table
CREATE TABLE `electrophysiology_uploader` (
`UploadID` int(10) unsigned NOT NULL AUTO_INCREMENT,
Expand Down Expand Up @@ -635,38 +543,83 @@ INSERT INTO ImagingFileTypes
('cnt', 'Neuroscan CNT data format (EEG)'),
('archive', 'Archive file');

-- Insert into annotation_file_type
INSERT INTO physiological_annotation_file_type
(FileType, Description)
VALUES
('tsv', 'TSV File Type, contains information about each annotation'),
('json', 'JSON File Type, metadata for annotations');

-- Insert into annotation_label_type
INSERT INTO physiological_annotation_label
(AnnotationLabelID, LabelName, LabelDescription)
VALUES
(1, 'artifact', 'artifactual data'),
(2, 'motion', 'motion related artifact'),
(3, 'flux_jump', 'artifactual data due to flux jump'),
(4, 'line_noise', 'artifactual data due to line noise (e.g., 50Hz)'),
(5, 'muscle', 'artifactual data due to muscle activity'),
(6, 'epilepsy_interictal', 'period deemed interictal'),
(7, 'epilepsy_preictal', 'onset of preictal state prior to onset of epilepsy'),
(8, 'epilepsy_seizure', 'onset of epilepsy'),
(9, 'epilepsy_postictal', 'postictal seizure period'),
(10, 'epileptiform', 'unspecified epileptiform activity'),
(11, 'epileptiform_single', 'a single epileptiform graphoelement (including possible slow wave)'),
(12, 'epileptiform_run', 'a run of one or more epileptiform graphoelements'),
(13, 'eye_blink', 'Eye blink'),
(14, 'eye_movement', 'Smooth Pursuit / Saccadic eye movement'),
(15, 'eye_fixation', 'Fixation onset'),
(16, 'sleep_N1', 'sleep stage N1'),
(17, 'sleep_N2', 'sleep stage N2'),
(18, 'sleep_N3', 'sleep stage N3'),
(19, 'sleep_REM', 'REM sleep'),
(20, 'sleep_wake', 'sleep stage awake'),
(21, 'sleep_spindle', 'sleep spindle'),
(22, 'sleep_k-complex', 'sleep K-complex'),
(23, 'scorelabeled', 'a global label indicating that the EEG has been annotated with SCORE.');
-- Create `hed_schema` table
CREATE TABLE `hed_schema` (
`ID` int(10) unsigned NOT NULL AUTO_INCREMENT,
`Name` varchar(255) NOT NULL,
`Version` varchar(255) NOT NULL,
`Description` text NULL,
`URL` varchar(255) NOT NULL UNIQUE,
PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- Create `hed_schema_nodes` table
CREATE TABLE `hed_schema_nodes` (
`ID` int(10) unsigned NOT NULL AUTO_INCREMENT,
`ParentID` int(10) unsigned NULL,
`SchemaID` int(10) unsigned NOT NULL,
`Name` varchar(255) NOT NULL,
`LongName` varchar(255) NOT NULL,
`Description` text NOT NULL,
PRIMARY KEY (`ID`),
CONSTRAINT `FK_hed_parent_node`
FOREIGN KEY (`ParentID`)
REFERENCES `hed_schema_nodes` (`ID`),
CONSTRAINT `FK_hed_schema` FOREIGN KEY (`SchemaID`) REFERENCES `hed_schema` (`ID`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- Create `physiological_task_event_hed_rel` table
CREATE TABLE `physiological_task_event_hed_rel` (
`ID` int(10) unsigned NOT NULL AUTO_INCREMENT,
`PhysiologicalTaskEventID` int(10) unsigned NOT NULL,
`HEDTagID` int(10) unsigned NULL, -- Reference to hed_schema_nodes.ID. Can be null to only add parentheses
`TagValue` text NULL, -- For value tags
`HasPairing` boolean DEFAULT FALSE, -- Is grouped with #AdditionalMembers# members
`PairRelID` int(10) unsigned NULL, -- The `ID` of right side of the pair
`AdditionalMembers` int(10) unsigned DEFAULT 0, -- Number of additional members to encapsulate
PRIMARY KEY (`ID`),
CONSTRAINT `FK_physiological_task_event_hed_rel_pair` FOREIGN KEY (`PairRelID`)
REFERENCES `physiological_task_event_hed_rel` (`ID`) ON DELETE CASCADE ON UPDATE CASCADE,
KEY `FK_physiological_task_event_hed_rel_2` (`HEDTagID`),
CONSTRAINT `FK_physiological_task_event_hed_rel_2` FOREIGN KEY (`HEDTagID`)
REFERENCES `hed_schema_nodes` (`ID`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `FK_physiological_task_event_hed_rel_1` FOREIGN KEY (`PhysiologicalTaskEventID`)
REFERENCES `physiological_task_event` (`PhysiologicalTaskEventID`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- Create `bids_event_dataset_mapping` table
CREATE TABLE `bids_event_dataset_mapping` (
`ID` int(10) unsigned NOT NULL AUTO_INCREMENT,
`ProjectID` int(10) unsigned NOT NULL,
`PropertyName` varchar(50) NOT NULL,
`PropertyValue` varchar(255) NOT NULL,
`HEDTagID` int(10) unsigned NULL, -- Reference to hed_schema_nodes.ID. Can be null to only add parentheses
`TagValue` text NULL, -- For value tags
`Description` TEXT NULL, -- Level Description
`HasPairing` BOOLEAN DEFAULT FALSE, -- Is grouped with #AdditionalMembers# members
`PairRelID` int(10) unsigned NULL, -- The `ID` of right side of the pair
`AdditionalMembers` int(10) unsigned DEFAULT 0, -- Number of additional members to encapsulate
PRIMARY KEY (`ID`),
INDEX idx_event_dataset_PropertyName_PropertyValue (`PropertyName`, `PropertyValue`),
CONSTRAINT `FK_project_id` FOREIGN KEY (`ProjectID`) REFERENCES `Project` (`ProjectID`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `FK_dataset_hed_tag_id` FOREIGN KEY (`HEDTagID`) REFERENCES `hed_schema_nodes` (`ID`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


-- Create `bids_event_file_mapping` table
CREATE TABLE `bids_event_file_mapping` (
`ID` int(10) unsigned NOT NULL AUTO_INCREMENT,
`EventFileID` int(10) unsigned NOT NULL,
`PropertyName` varchar(50) NOT NULL,
`PropertyValue` varchar(255) NOT NULL,
`HEDTagID` int(10) unsigned NULL, -- Reference to hed_schema_nodes.ID. Can be null to only add parentheses
`TagValue` text NULL, -- For value tags
`Description` TEXT NULL, -- Level Description
`HasPairing` BOOLEAN DEFAULT FALSE, -- Is grouped with #AdditionalMembers# members
`PairRelID` int(10) unsigned NULL, -- The `ID` of right side of the pair
`AdditionalMembers` int(10) unsigned DEFAULT 0, -- Number of additional members to encapsulate
PRIMARY KEY (`ID`),
INDEX idx_event_file_PropertyName_PropertyValue (`PropertyName`, `PropertyValue`),
CONSTRAINT `FK_event_mapping_file_id` FOREIGN KEY (`EventFileID`) REFERENCES `physiological_event_file` (`EventFileID`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `FK_file_hed_tag_id` FOREIGN KEY (`HEDTagID`) REFERENCES `hed_schema_nodes` (`ID`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
-- Dropping all tables regarding annotations
DROP TABLE physiological_annotation_archive;
DROP TABLE physiological_annotation_rel;
DROP TABLE physiological_annotation_instance;
DROP TABLE physiological_annotation_parameter;
DROP TABLE physiological_annotation_label;
DROP TABLE physiological_annotation_file;
DROP TABLE physiological_annotation_file_type;

-- Event files are always associated to Projects, sometimes exclusively (dataset-scope events.json files)
-- Add ProjectID and make PhysiologicalFileID DEFAULT NULL (ProjectID should ideally not be NULLable)
ALTER TABLE `physiological_event_file`
CHANGE `PhysiologicalFileID` `PhysiologicalFileID` int(10) unsigned DEFAULT NULL,
ADD COLUMN `ProjectID` int(10) unsigned DEFAULT NULL AFTER `PhysiologicalFileID`,
ADD KEY `FK_physiological_event_file_project_id` (`ProjectID`),
ADD CONSTRAINT `FK_physiological_event_file_project_id`
FOREIGN KEY (`ProjectID`) REFERENCES `Project` (`ProjectID`);
Loading

0 comments on commit 21b2b4d

Please sign in to comment.