From 8cbc94758b7bdbbc6edca4e49148862415c0f100 Mon Sep 17 00:00:00 2001 From: jesscall Date: Thu, 3 Mar 2022 14:25:24 -0500 Subject: [PATCH 1/7] DB tables for HED Tags --- SQL/0000-00-00-schema.sql | 3 +- SQL/0000-00-05-ElectrophysiologyTables.sql | 93 +++++++++++++- SQL/New_patches/2022-03-03-AddHEDTags.sql | 116 ++++++++++++++++++ .../php/sessions.class.inc | 4 +- tools/single_use/archive_eeg_event_files.php | 42 +++++++ 5 files changed, 251 insertions(+), 7 deletions(-) create mode 100644 SQL/New_patches/2022-03-03-AddHEDTags.sql create mode 100644 tools/single_use/archive_eeg_event_files.php diff --git a/SQL/0000-00-00-schema.sql b/SQL/0000-00-00-schema.sql index 956ca82c83a..a5043494f2b 100644 --- a/SQL/0000-00-00-schema.sql +++ b/SQL/0000-00-00-schema.sql @@ -1715,7 +1715,8 @@ INSERT INTO `parameter_type` (Name, Alias, Type, Description, SourceFrom) VALUES ('fov_dimensions','FieldOfViewDimensions','text','Dimensions of the field of view, in mm. If Field of View Shape (0018,1147) is: RECTANGLE: row dimension followed by column. ROUND: diameter. HEXAGONAL: diameter of a circumscribed circle. DICOM:0018_1149','parameter_file'), ('laterality','Laterality','text','Laterality of (paired) body part examined. Required if the body part examined is a paired structure and Image Laterality (0020,0062) or Frame Laterality (0020,9072) are not sent. DICOM:0020_0060','parameter_file'), ('position_reference_indicator','PositionReferenceIndicator','text','Part of the imaging target used as a reference. DICOM:0020_1040','parameter_file'), - ('pixel_padding_value','PixelPaddingValue','text','Value of pixels added to non-rectangular image to pad to rectangular format. DICOM:0028_0120','parameter_file'); + ('pixel_padding_value','PixelPaddingValue','text','Value of pixels added to non-rectangular image to pad to rectangular format. DICOM:0028_0120','parameter_file'), + ('HEDVersion', 'HEDVersion', 'text', 'HED Schema Version','physiological_parameter_file'); CREATE TABLE `parameter_type_category` ( `ParameterTypeCategoryID` int(11) unsigned NOT NULL auto_increment, diff --git a/SQL/0000-00-05-ElectrophysiologyTables.sql b/SQL/0000-00-05-ElectrophysiologyTables.sql index def2d4c89d4..50fc3432097 100644 --- a/SQL/0000-00-05-ElectrophysiologyTables.sql +++ b/SQL/0000-00-05-ElectrophysiologyTables.sql @@ -180,13 +180,37 @@ CREATE TABLE `physiological_electrode` ( REFERENCES `physiological_electrode_material` (`PhysiologicalElectrodeMaterialID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; - +-- Create `physiological_event_file_type` table +CREATE TABLE `physiological_event_file_type` ( + `FileType` varchar(20) NOT NULL, + `Description` varchar(255) DEFAULT NULL, + PRIMARY KEY (`FileType`), + UNIQUE KEY `FileType` (`FileType`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 +; + +-- Create `physiological_event_file` table +CREATE TABLE `physiological_event_file` ( + `EventFileID` int(10) unsigned NOT NULL AUTO_INCREMENT, + `PhysiologicalFileID` int(10) unsigned NOT NULL, + `FileType` varchar(20) NOT NULL, + `FilePath` varchar(255) DEFAULT NULL, + `LastUpdate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `LastWritten` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`EventFileID`), + KEY `FK_physio_file_ID` (`PhysiologicalFileID`), + KEY `FK_event_file_type` (`FileType`), + CONSTRAINT `FK_event_file_type` FOREIGN KEY (`FileType`) REFERENCES `physiological_event_file_type` (`FileType`), + CONSTRAINT `FK_physio_file_ID` FOREIGN KEY (`PhysiologicalFileID`) REFERENCES `physiological_file` (`PhysiologicalFileID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 +; -- Create physiological_task_event table that will store all information -- regarding the task executed during the physiological recording CREATE TABLE `physiological_task_event` ( `PhysiologicalTaskEventID` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, `PhysiologicalFileID` INT(10) UNSIGNED NOT NULL, + `EventFileID` INT(10) unsigned NOT NULL, `InsertTime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, `Onset` DECIMAL(11,6) NOT NULL, `Duration` DECIMAL(11,6) NOT NULL, @@ -196,15 +220,70 @@ CREATE TABLE `physiological_task_event` ( `EventType` VARCHAR(50) DEFAULT NULL, `TrialType` VARCHAR(255) DEFAULT NULL, `ResponseTime` TIME DEFAULT NULL, - `FilePath` VARCHAR(255) DEFAULT NULL, PRIMARY KEY (`PhysiologicalTaskEventID`), + KEY `FK_event_file` (`EventFileID`), CONSTRAINT `FK_phys_file_FileID_4` FOREIGN KEY (`PhysiologicalFileID`) REFERENCES `physiological_file` (`PhysiologicalFileID`) - ON DELETE CASCADE + ON DELETE CASCADE, + CONSTRAINT `FK_event_file` + FOREIGN KEY (`EventFileID`) + REFERENCES `physiological_event_file` (`EventFileID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; - +-- Create `physiological_event_archive` to store event archive info +CREATE TABLE `physiological_event_archive` ( + `EventArchiveID` 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 (`EventArchiveID`), + KEY `FK_phy_file_ID` (`PhysiologicalFileID`), + CONSTRAINT `FK_phy_file_ID` FOREIGN KEY (`PhysiologicalFileID`) REFERENCES `physiological_file` (`PhysiologicalFileID`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8 +; + +-- Create `physiological_event_parameter` to capture all event parameters +-- from events.json +CREATE TABLE `physiological_event_parameter` ( + `EventParameterID` int(10) unsigned NOT NULL AUTO_INCREMENT, + `EventFileID` int(10) unsigned NOT NULL, + `ParameterName` varchar(255) NOT NULL, + `Description` text NOT NULL, + `LongName` varchar(255) DEFAULT NULL, + `Units` varchar(50) DEFAULT NULL, + `isCategorical` enum('Y', 'N') DEFAULT NULL, + `HED` text DEFAULT NULL, + PRIMARY KEY (`EventParameterID`), + KEY `FK_event_file_ID` (`EventFileID`), + CONSTRAINT `FK_event_file_ID` FOREIGN KEY (`EventFileID`) REFERENCES `physiological_event_file` (`EventFileID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 +; + +-- Create `physiological_event_parameter_category_level` to capture +-- category levels from events.json +CREATE TABLE `physiological_event_parameter_category_level` ( + `CategoricalLevelID` int(10) unsigned NOT NULL AUTO_INCREMENT, + `EventParameterID` int(10) unsigned NOT NULL, + `LevelName` varchar(255) NOT NULL, + `Description` text NOT NULL, + `HED` text DEFAULT NULL, + PRIMARY KEY (`CategoricalLevelID`), + KEY `FK_event_param_ID` (`EventParameterID`), + CONSTRAINT `FK_event_param_ID` FOREIGN KEY (`EventParameterID`) REFERENCES `physiological_event_parameter` (`EventParameterID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 +; + +-- Create `physiological_event_assembled_hed_tag` to store assembled HED Tags +CREATE TABLE `physiological_event_assembled_hed_tag` ( + `TaskEventID` int(10) unsigned NOT NULL, + `EventParameterID` int(10) unsigned NOT NULL, + `AssembledHED` text NOT NULL, + PRIMARY KEY (`TaskEventID`, `EventParameterID`), + CONSTRAINT `FK_task_event_ID` FOREIGN KEY (`TaskEventID`) REFERENCES `physiological_task_event` (`PhysiologicalTaskEventID`), + CONSTRAINT `FK_event_parameter_ID` FOREIGN KEY (`EventParameterID`) REFERENCES `physiological_event_parameter` (`EventParameterID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 +; -- Create physiological_archive which will store archives of all the files for -- Front-end download @@ -426,3 +505,9 @@ INSERT INTO physiological_annotation_label (22, 'sleep_k-complex', 'sleep K-complex'), (23, 'scorelabeled', 'a global label indicating that the EEG has been annotated with SCORE.'); +-- Insert file types (json, tsv) +INSERT INTO physiological_event_file_type (FileType, Description) VALUES + ('json', 'JSON File Type, sidecar for event metadata'), + ('tsv', 'TSV File Type, contains information about each event') +; + diff --git a/SQL/New_patches/2022-03-03-AddHEDTags.sql b/SQL/New_patches/2022-03-03-AddHEDTags.sql new file mode 100644 index 00000000000..fffd460efeb --- /dev/null +++ b/SQL/New_patches/2022-03-03-AddHEDTags.sql @@ -0,0 +1,116 @@ +-- ############################## CAPTURE HEDVersion ########################## -- +-- HEDVersion from dataset_description.json to be added to parameter_type +-- Entry in physiological_parameter_file will be added on dataset import** +INSERT INTO parameter_type (Name, Type, Description, SourceFrom) VALUES + ('HEDVersion', 'text', 'HED Schema Version','physiological_parameter_file') +; + +-- ############################## HANDLE EVENT FILES ########################## -- +-- Create `physiological_event_file_type` table +CREATE TABLE `physiological_event_file_type` ( + `FileType` varchar(20) NOT NULL, + `Description` varchar(255) DEFAULT NULL, + PRIMARY KEY (`FileType`), + UNIQUE KEY `FileType` (`FileType`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 +; + +-- Insert file types (json, tsv) +INSERT INTO physiological_event_file_type (FileType, Description) VALUES + ('json', 'JSON File Type, sidecar for event metadata'), + ('tsv', 'TSV File Type, contains information about each event') +; + +-- Create `physiological_event_file` table +CREATE TABLE `physiological_event_file` ( + `EventFileID` int(10) unsigned NOT NULL AUTO_INCREMENT, + `PhysiologicalFileID` int(10) unsigned NOT NULL, + `FileType` varchar(20) NOT NULL, + `FilePath` varchar(255) DEFAULT NULL, + `LastUpdate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `LastWritten` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`EventFileID`), + KEY `FK_physio_file_ID` (`PhysiologicalFileID`), + KEY `FK_event_file_type` (`FileType`), + CONSTRAINT `FK_event_file_type` FOREIGN KEY (`FileType`) REFERENCES `physiological_event_file_type` (`FileType`), + CONSTRAINT `FK_physio_file_ID` FOREIGN KEY (`PhysiologicalFileID`) REFERENCES `physiological_file` (`PhysiologicalFileID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 +; + +-- Create reference to EventFileID in `physiological_task_event` table +SET FOREIGN_KEY_CHECKS= 0; +ALTER TABLE physiological_task_event + ADD COLUMN `EventFileID` int(10) unsigned NOT NULL AFTER PhysiologicalFileID, + ADD KEY `FK_event_file` (`EventFileID`), + ADD CONSTRAINT `FK_event_file` FOREIGN KEY (`EventFileID`) REFERENCES `physiological_event_file` (`EventFileID`) +; + +-- Insert files into `physiological_event_file` table +INSERT INTO physiological_event_file (PhysiologicalFileID, FilePath, FileType) + SELECT DISTINCT PhysiologicalFileID, FilePath, 'tsv' FROM physiological_task_event +; + +-- Update EventFileID reference in `physiological_task_event` table +UPDATE physiological_task_event te + SET EventFileID=(SELECT EventFileID FROM physiological_event_file WHERE PhysiologicalFileID=te.PhysiologicalFileID) +; + +-- Delete FilePath column in `physiological_task_event` table +ALTER TABLE physiological_task_event + DROP COLUMN FilePath +; + + +-- ############################## EVENT FILES ARCHIVE ########################## -- +CREATE TABLE `physiological_event_archive` ( + `EventArchiveID` 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 (`EventArchiveID`), + KEY `FK_phy_file_ID` (`PhysiologicalFileID`), + CONSTRAINT `FK_phy_file_ID` FOREIGN KEY (`PhysiologicalFileID`) REFERENCES `physiological_file` (`PhysiologicalFileID`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8 +; + + +-- ############################## CAPTURE EVENT PARAMETERS ########################## -- +CREATE TABLE `physiological_event_parameter` ( + `EventParameterID` int(10) unsigned NOT NULL AUTO_INCREMENT, + `EventFileID` int(10) unsigned NOT NULL, + `ParameterName` varchar(255) NOT NULL, + `Description` text NOT NULL, + `LongName` varchar(255) DEFAULT NULL, + `Units` varchar(50) DEFAULT NULL, + `isCategorical` enum('Y', 'N') DEFAULT NULL, + `HED` text DEFAULT NULL, + PRIMARY KEY (`EventParameterID`), + KEY `FK_event_file_ID` (`EventFileID`), + CONSTRAINT `FK_event_file_ID` FOREIGN KEY (`EventFileID`) REFERENCES `physiological_event_file` (`EventFileID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 +; + +CREATE TABLE `physiological_event_parameter_category_level` ( + `CategoricalLevelID` int(10) unsigned NOT NULL AUTO_INCREMENT, + `EventParameterID` int(10) unsigned NOT NULL, + `LevelName` varchar(255) NOT NULL, + `Description` text NOT NULL, + `HED` text DEFAULT NULL, + PRIMARY KEY (`CategoricalLevelID`), + KEY `FK_event_param_ID` (`EventParameterID`), + CONSTRAINT `FK_event_param_ID` FOREIGN KEY (`EventParameterID`) REFERENCES `physiological_event_parameter` (`EventParameterID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 +; + + +-- ############################## STORE ASSEMBLED HED TAGS ########################## -- +CREATE TABLE `physiological_event_assembled_hed_tag` ( + `TaskEventID` int(10) unsigned NOT NULL, + `EventParameterID` int(10) unsigned NOT NULL, + `AssembledHED` text NOT NULL, + PRIMARY KEY (`TaskEventID`, `EventParameterID`), + CONSTRAINT `FK_task_event_ID` FOREIGN KEY (`TaskEventID`) REFERENCES `physiological_task_event` (`PhysiologicalTaskEventID`), + CONSTRAINT `FK_event_parameter_ID` FOREIGN KEY (`EventParameterID`) REFERENCES `physiological_event_parameter` (`EventParameterID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 +; + diff --git a/modules/electrophysiology_browser/php/sessions.class.inc b/modules/electrophysiology_browser/php/sessions.class.inc index c4070a623b3..ecb27901711 100644 --- a/modules/electrophysiology_browser/php/sessions.class.inc +++ b/modules/electrophysiology_browser/php/sessions.class.inc @@ -548,7 +548,7 @@ class Sessions extends \NDB_Page $queries = [ 'physiological_electrode' => 'physiological_electrode_file', 'physiological_channel' => 'physiological_channel_file', - 'physiological_task_event' => 'physiological_task_event_file', + 'physiological_event_archive' => 'physiological_event_files', 'physiological_annotation_archive' => 'physiological_annotation_files', 'physiological_archive' => 'all_files', ]; @@ -556,7 +556,7 @@ class Sessions extends \NDB_Page $labels = [ 'physiological_electrode_file' => 'Electrodes', 'physiological_channel_file' => 'Channels', - 'physiological_task_event_file' => 'Events', + 'physiological_event_files' => 'Events', 'physiological_annotation_files' => 'Annotations', 'all_files' => 'All Files', ]; diff --git a/tools/single_use/archive_eeg_event_files.php b/tools/single_use/archive_eeg_event_files.php new file mode 100644 index 00000000000..8ec2becc780 --- /dev/null +++ b/tools/single_use/archive_eeg_event_files.php @@ -0,0 +1,42 @@ +database(); + +$dataDir = $db->pselectOne( + 'SELECT Value + FROM Config AS config + INNER JOIN ConfigSettings AS c + ON c.Name=:name AND config.ConfigID=c.ID', + ['name' => 'dataDirBasepath'] +); + +$filepaths = $db->pselect( + "SELECT + DISTINCT(FilePath), PhysiologicalFileID + FROM physiological_event_file + WHERE FileType='tsv'", + [] +); + +foreach ($filepaths as $record) { + $tgz_name = str_replace(".tsv", '.tgz', $record['FilePath']); + $tgz_path = $dataDir . $tgz_name; + print_r($tgz_path . "\n"); + $eventPath = $dataDir . $record['FilePath']; + $arch_file = new \PharData($tgz_path); + $arch_file->addFile($eventPath, basename($eventPath)); + + $f = file_get_contents($tgz_path); + $hash = sodium_crypto_generichash($f); + + //Update database with hash + $db->insert( + 'physiological_event_archive', + [ + 'PhysiologicalFileID' => $record['PhysiologicalFileID'], + 'FilePath' => str_replace($dataDir, '', $tgz_path), + 'Blake2bHash' => bin2hex($hash) + ] + ); +} From 82112f47341f5e6acff837bb98a1d7f18f831598 Mon Sep 17 00:00:00 2001 From: jesscall Date: Mon, 7 Mar 2022 11:27:45 -0500 Subject: [PATCH 2/7] viz bugfixes events file access --- .../jsx/electrophysiologySessionView.js | 11 ++++------- .../electrophysiology_browser/php/sessions.class.inc | 9 ++++++++- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/modules/electrophysiology_browser/jsx/electrophysiologySessionView.js b/modules/electrophysiology_browser/jsx/electrophysiologySessionView.js index 638e79fcb54..dfc501d0a70 100644 --- a/modules/electrophysiology_browser/jsx/electrophysiologySessionView.js +++ b/modules/electrophysiology_browser/jsx/electrophysiologySessionView.js @@ -206,13 +206,10 @@ class ElectrophysiologySessionView extends Component { ), epochsURL: dbEntry - && dbEntry.file.downloads.map( - (group) => - group.links[3]?.file - && loris.BaseURL - + '/electrophysiology_browser/file_reader/?file=' - + group.links[3].file - ), + && dbEntry.file?.epochsURL + && [loris.BaseURL + + '/electrophysiology_browser/file_reader/?file=' + + dbEntry.file.epochsURL], electrodesURL: dbEntry && dbEntry.file.downloads.map( diff --git a/modules/electrophysiology_browser/php/sessions.class.inc b/modules/electrophysiology_browser/php/sessions.class.inc index ecb27901711..ab7dfc46c63 100644 --- a/modules/electrophysiology_browser/php/sessions.class.inc +++ b/modules/electrophysiology_browser/php/sessions.class.inc @@ -459,7 +459,14 @@ class Sessions extends \NDB_Page // get the links to the files for downloads $fileSummary['downloads'] = $this->getDownloadLinks($physioFileObj); - $fileSummary['chunks_urls'] = $physioFileObj->getChunksURLs(); + $fileSummary['chunks_urls'] = $physioFileObj->getChunksURLs(); + $fileSummary['epochsURL'] = $db->pselectOne( + "SELECT FilePath + FROM physiological_event_file + WHERE PhysiologicalFileID=:physioFileID + AND FileType='tsv'", + ['physioFileID' => $physioFileID] + ); $fileOutput = $db->pselectone( 'SELECT pot.OutputTypeName From 0d6cef9676c26073b199225c0a5e60f4e164d5c0 Mon Sep 17 00:00:00 2001 From: Jessica Callegaro <34260251+jesscall@users.noreply.github.com> Date: Wed, 9 Mar 2022 13:06:41 -0500 Subject: [PATCH 3/7] make param description nullable --- SQL/0000-00-05-ElectrophysiologyTables.sql | 4 ++-- SQL/New_patches/2022-03-03-AddHEDTags.sql | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/SQL/0000-00-05-ElectrophysiologyTables.sql b/SQL/0000-00-05-ElectrophysiologyTables.sql index 50fc3432097..4583d240c96 100644 --- a/SQL/0000-00-05-ElectrophysiologyTables.sql +++ b/SQL/0000-00-05-ElectrophysiologyTables.sql @@ -249,7 +249,7 @@ CREATE TABLE `physiological_event_parameter` ( `EventParameterID` int(10) unsigned NOT NULL AUTO_INCREMENT, `EventFileID` int(10) unsigned NOT NULL, `ParameterName` varchar(255) NOT NULL, - `Description` text NOT NULL, + `Description` text DEFAULT NULL, `LongName` varchar(255) DEFAULT NULL, `Units` varchar(50) DEFAULT NULL, `isCategorical` enum('Y', 'N') DEFAULT NULL, @@ -266,7 +266,7 @@ CREATE TABLE `physiological_event_parameter_category_level` ( `CategoricalLevelID` int(10) unsigned NOT NULL AUTO_INCREMENT, `EventParameterID` int(10) unsigned NOT NULL, `LevelName` varchar(255) NOT NULL, - `Description` text NOT NULL, + `Description` text DEFAULT NULL, `HED` text DEFAULT NULL, PRIMARY KEY (`CategoricalLevelID`), KEY `FK_event_param_ID` (`EventParameterID`), diff --git a/SQL/New_patches/2022-03-03-AddHEDTags.sql b/SQL/New_patches/2022-03-03-AddHEDTags.sql index fffd460efeb..285589b9733 100644 --- a/SQL/New_patches/2022-03-03-AddHEDTags.sql +++ b/SQL/New_patches/2022-03-03-AddHEDTags.sql @@ -79,7 +79,7 @@ CREATE TABLE `physiological_event_parameter` ( `EventParameterID` int(10) unsigned NOT NULL AUTO_INCREMENT, `EventFileID` int(10) unsigned NOT NULL, `ParameterName` varchar(255) NOT NULL, - `Description` text NOT NULL, + `Description` text DEFAULT NULL, `LongName` varchar(255) DEFAULT NULL, `Units` varchar(50) DEFAULT NULL, `isCategorical` enum('Y', 'N') DEFAULT NULL, @@ -94,7 +94,7 @@ CREATE TABLE `physiological_event_parameter_category_level` ( `CategoricalLevelID` int(10) unsigned NOT NULL AUTO_INCREMENT, `EventParameterID` int(10) unsigned NOT NULL, `LevelName` varchar(255) NOT NULL, - `Description` text NOT NULL, + `Description` text DEFAULT NULL, `HED` text DEFAULT NULL, PRIMARY KEY (`CategoricalLevelID`), KEY `FK_event_param_ID` (`EventParameterID`), From aa07a6dfe701ff791b65c5373bbbaaf8d19b84a5 Mon Sep 17 00:00:00 2001 From: jesscall Date: Tue, 17 May 2022 14:21:05 -0400 Subject: [PATCH 4/7] move AssembledHED to physiological_task_event --- SQL/0000-00-05-ElectrophysiologyTables.sql | 12 +----------- SQL/New_patches/2022-03-03-AddHEDTags.sql | 18 +++++------------- 2 files changed, 6 insertions(+), 24 deletions(-) diff --git a/SQL/0000-00-05-ElectrophysiologyTables.sql b/SQL/0000-00-05-ElectrophysiologyTables.sql index 4583d240c96..110435a0a5e 100644 --- a/SQL/0000-00-05-ElectrophysiologyTables.sql +++ b/SQL/0000-00-05-ElectrophysiologyTables.sql @@ -220,6 +220,7 @@ 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`), CONSTRAINT `FK_phys_file_FileID_4` @@ -274,17 +275,6 @@ CREATE TABLE `physiological_event_parameter_category_level` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ; --- Create `physiological_event_assembled_hed_tag` to store assembled HED Tags -CREATE TABLE `physiological_event_assembled_hed_tag` ( - `TaskEventID` int(10) unsigned NOT NULL, - `EventParameterID` int(10) unsigned NOT NULL, - `AssembledHED` text NOT NULL, - PRIMARY KEY (`TaskEventID`, `EventParameterID`), - CONSTRAINT `FK_task_event_ID` FOREIGN KEY (`TaskEventID`) REFERENCES `physiological_task_event` (`PhysiologicalTaskEventID`), - CONSTRAINT `FK_event_parameter_ID` FOREIGN KEY (`EventParameterID`) REFERENCES `physiological_event_parameter` (`EventParameterID`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 -; - -- Create physiological_archive which will store archives of all the files for -- Front-end download CREATE TABLE `physiological_archive` ( diff --git a/SQL/New_patches/2022-03-03-AddHEDTags.sql b/SQL/New_patches/2022-03-03-AddHEDTags.sql index 285589b9733..861f225d1ea 100644 --- a/SQL/New_patches/2022-03-03-AddHEDTags.sql +++ b/SQL/New_patches/2022-03-03-AddHEDTags.sql @@ -45,6 +45,11 @@ ALTER TABLE physiological_task_event ADD CONSTRAINT `FK_event_file` FOREIGN KEY (`EventFileID`) REFERENCES `physiological_event_file` (`EventFileID`) ; +-- Create column for assembled HEd tags in `physiological_task_event` table +ALTER TABLE physiological_task_event + ADD COLUMN `AssembledHED` text DEFAULT NULL +; + -- Insert files into `physiological_event_file` table INSERT INTO physiological_event_file (PhysiologicalFileID, FilePath, FileType) SELECT DISTINCT PhysiologicalFileID, FilePath, 'tsv' FROM physiological_task_event @@ -101,16 +106,3 @@ CREATE TABLE `physiological_event_parameter_category_level` ( CONSTRAINT `FK_event_param_ID` FOREIGN KEY (`EventParameterID`) REFERENCES `physiological_event_parameter` (`EventParameterID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ; - - --- ############################## STORE ASSEMBLED HED TAGS ########################## -- -CREATE TABLE `physiological_event_assembled_hed_tag` ( - `TaskEventID` int(10) unsigned NOT NULL, - `EventParameterID` int(10) unsigned NOT NULL, - `AssembledHED` text NOT NULL, - PRIMARY KEY (`TaskEventID`, `EventParameterID`), - CONSTRAINT `FK_task_event_ID` FOREIGN KEY (`TaskEventID`) REFERENCES `physiological_task_event` (`PhysiologicalTaskEventID`), - CONSTRAINT `FK_event_parameter_ID` FOREIGN KEY (`EventParameterID`) REFERENCES `physiological_event_parameter` (`EventParameterID`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 -; - From 19d70cb4f94b90ba9411b5233ced097554c1a48b Mon Sep 17 00:00:00 2001 From: jesscall Date: Tue, 14 Jun 2022 11:38:46 -0400 Subject: [PATCH 5/7] phpcs --- modules/electrophysiology_browser/php/sessions.class.inc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/electrophysiology_browser/php/sessions.class.inc b/modules/electrophysiology_browser/php/sessions.class.inc index ab7dfc46c63..0cb63f0baaa 100644 --- a/modules/electrophysiology_browser/php/sessions.class.inc +++ b/modules/electrophysiology_browser/php/sessions.class.inc @@ -459,8 +459,8 @@ class Sessions extends \NDB_Page // get the links to the files for downloads $fileSummary['downloads'] = $this->getDownloadLinks($physioFileObj); - $fileSummary['chunks_urls'] = $physioFileObj->getChunksURLs(); - $fileSummary['epochsURL'] = $db->pselectOne( + $fileSummary['chunks_urls'] = $physioFileObj->getChunksURLs(); + $fileSummary['epochsURL'] = $db->pselectOne( "SELECT FilePath FROM physiological_event_file WHERE PhysiologicalFileID=:physioFileID @@ -555,7 +555,7 @@ class Sessions extends \NDB_Page $queries = [ 'physiological_electrode' => 'physiological_electrode_file', 'physiological_channel' => 'physiological_channel_file', - 'physiological_event_archive' => 'physiological_event_files', + 'physiological_event_archive' => 'physiological_event_files', 'physiological_annotation_archive' => 'physiological_annotation_files', 'physiological_archive' => 'all_files', ]; From cc07a82ef15f91f55f93011a836f2d8ecdfd13ca Mon Sep 17 00:00:00 2001 From: Jessica Callegaro <34260251+jesscall@users.noreply.github.com> Date: Tue, 21 Jun 2022 11:23:01 -0400 Subject: [PATCH 6/7] use ImagingFileTypes table --- SQL/New_patches/2022-03-03-AddHEDTags.sql | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/SQL/New_patches/2022-03-03-AddHEDTags.sql b/SQL/New_patches/2022-03-03-AddHEDTags.sql index 861f225d1ea..18119bfc089 100644 --- a/SQL/New_patches/2022-03-03-AddHEDTags.sql +++ b/SQL/New_patches/2022-03-03-AddHEDTags.sql @@ -6,21 +6,6 @@ INSERT INTO parameter_type (Name, Type, Description, SourceFrom) VALUES ; -- ############################## HANDLE EVENT FILES ########################## -- --- Create `physiological_event_file_type` table -CREATE TABLE `physiological_event_file_type` ( - `FileType` varchar(20) NOT NULL, - `Description` varchar(255) DEFAULT NULL, - PRIMARY KEY (`FileType`), - UNIQUE KEY `FileType` (`FileType`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 -; - --- Insert file types (json, tsv) -INSERT INTO physiological_event_file_type (FileType, Description) VALUES - ('json', 'JSON File Type, sidecar for event metadata'), - ('tsv', 'TSV File Type, contains information about each event') -; - -- Create `physiological_event_file` table CREATE TABLE `physiological_event_file` ( `EventFileID` int(10) unsigned NOT NULL AUTO_INCREMENT, @@ -32,7 +17,7 @@ CREATE TABLE `physiological_event_file` ( PRIMARY KEY (`EventFileID`), KEY `FK_physio_file_ID` (`PhysiologicalFileID`), KEY `FK_event_file_type` (`FileType`), - CONSTRAINT `FK_event_file_type` FOREIGN KEY (`FileType`) REFERENCES `physiological_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`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ; From 1d83acab3ca4e3e0d113d9d51f37ed7e2c3b7c38 Mon Sep 17 00:00:00 2001 From: Jessica Callegaro <34260251+jesscall@users.noreply.github.com> Date: Tue, 21 Jun 2022 11:25:21 -0400 Subject: [PATCH 7/7] use ImagingFileTypes for physio event files --- SQL/0000-00-05-ElectrophysiologyTables.sql | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/SQL/0000-00-05-ElectrophysiologyTables.sql b/SQL/0000-00-05-ElectrophysiologyTables.sql index 110435a0a5e..4ecbf9c36cf 100644 --- a/SQL/0000-00-05-ElectrophysiologyTables.sql +++ b/SQL/0000-00-05-ElectrophysiologyTables.sql @@ -180,15 +180,6 @@ CREATE TABLE `physiological_electrode` ( REFERENCES `physiological_electrode_material` (`PhysiologicalElectrodeMaterialID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; --- Create `physiological_event_file_type` table -CREATE TABLE `physiological_event_file_type` ( - `FileType` varchar(20) NOT NULL, - `Description` varchar(255) DEFAULT NULL, - PRIMARY KEY (`FileType`), - UNIQUE KEY `FileType` (`FileType`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 -; - -- Create `physiological_event_file` table CREATE TABLE `physiological_event_file` ( `EventFileID` int(10) unsigned NOT NULL AUTO_INCREMENT, @@ -200,7 +191,7 @@ CREATE TABLE `physiological_event_file` ( PRIMARY KEY (`EventFileID`), KEY `FK_physio_file_ID` (`PhysiologicalFileID`), KEY `FK_event_file_type` (`FileType`), - CONSTRAINT `FK_event_file_type` FOREIGN KEY (`FileType`) REFERENCES `physiological_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`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ; @@ -495,9 +486,3 @@ INSERT INTO physiological_annotation_label (22, 'sleep_k-complex', 'sleep K-complex'), (23, 'scorelabeled', 'a global label indicating that the EEG has been annotated with SCORE.'); --- Insert file types (json, tsv) -INSERT INTO physiological_event_file_type (FileType, Description) VALUES - ('json', 'JSON File Type, sidecar for event metadata'), - ('tsv', 'TSV File Type, contains information about each event') -; -