From 0fe247e32a4f1f795ce51409c85c094fa9b1fb7b Mon Sep 17 00:00:00 2001 From: Laetitia Fesselier Date: Tue, 28 Mar 2023 12:37:22 -0400 Subject: [PATCH] [EEG] Electrodes query and file download fix (#8478) PR #8242 modified the electrodes DB schemas and since then, the EEG Browser is broken. This fixes the issue by rewriting the query logic. Also fixes a few issues with the download buttons and the layout. --- .../css/electrophysiology_browser.css | 5 ++-- .../jsx/components/DownloadPanel.js | 1 - .../src/series/components/EventManager.tsx | 3 --- .../models/electrophysioannotations.class.inc | 12 +++++---- .../php/sessions.class.inc | 26 +++++++++++++++++-- 5 files changed, 34 insertions(+), 13 deletions(-) diff --git a/modules/electrophysiology_browser/css/electrophysiology_browser.css b/modules/electrophysiology_browser/css/electrophysiology_browser.css index 08aa9060ca4..a97cb229417 100644 --- a/modules/electrophysiology_browser/css/electrophysiology_browser.css +++ b/modules/electrophysiology_browser/css/electrophysiology_browser.css @@ -45,7 +45,7 @@ svg { .list-group-item { position: relative; display: flex; - flex-direction: row; + flex-direction: column; justify-content: space-between; align-items: center; } @@ -65,13 +65,14 @@ svg { justify-content: center; align-items: center; position: absolute; - right: 0; + right: 10px; } .epoch-tag { padding: 5px; background: #e7e4e4; border-left: 5px solid #797878; + width: 100%; } .epoch-tag p { diff --git a/modules/electrophysiology_browser/jsx/components/DownloadPanel.js b/modules/electrophysiology_browser/jsx/components/DownloadPanel.js index 4bce3b90130..027395c1c0b 100644 --- a/modules/electrophysiology_browser/jsx/components/DownloadPanel.js +++ b/modules/electrophysiology_browser/jsx/components/DownloadPanel.js @@ -95,7 +95,6 @@ class DownloadPanel extends Component { : '/mri/jiv/get_file.php?file=' + download.file } target='_blank' - download style={{ margin: 0, }} diff --git a/modules/electrophysiology_browser/jsx/react-series-data-viewer/src/series/components/EventManager.tsx b/modules/electrophysiology_browser/jsx/react-series-data-viewer/src/series/components/EventManager.tsx index 69a0daae007..fdbc1481e4b 100644 --- a/modules/electrophysiology_browser/jsx/react-series-data-viewer/src/series/components/EventManager.tsx +++ b/modules/electrophysiology_browser/jsx/react-series-data-viewer/src/series/components/EventManager.tsx @@ -187,9 +187,6 @@ const EventManager = ({ (epoch.type == 'Annotation' ? 'annotation ' : '') + 'list-group-item list-group-item-action' } - style={{ - position: 'relative', - }} >
_createFiles(); //Get new annotation file ID $annotation_tsv_ID = $db->pselectOne( @@ -164,8 +166,6 @@ class ElectrophysioAnnotations ); $metadata['AnnotationFileID'] = $annotation_json_ID; - $instance['AnnotationFileID'] = $annotation_tsv_ID; - $db->insert("physiological_annotation_parameter", $metadata); //Get new metadata file ID @@ -176,8 +176,8 @@ class ElectrophysioAnnotations ['annotation_ID' => $annotation_json_ID] ); + $instance['AnnotationFileID'] = $annotation_tsv_ID; $instance['AnnotationParameterID'] = $metadata_ID; - $db->insert("physiological_annotation_instance", $instance); } else { @@ -584,8 +584,10 @@ class ElectrophysioAnnotations WHERE PhysiologicalFileID=:PFID", ['PFID' => $this->_physioFileID] ); - $filepath = $dataDir.$filepath; - + if (!$filepath) { + continue; + } + $filepath = $dataDir.$filepath; $arch_file = new \PharData($filepath); foreach ($paths as $path) { $arch_file->addFile($path, basename($path)); diff --git a/modules/electrophysiology_browser/php/sessions.class.inc b/modules/electrophysiology_browser/php/sessions.class.inc index a8be5638960..ee68788834f 100644 --- a/modules/electrophysiology_browser/php/sessions.class.inc +++ b/modules/electrophysiology_browser/php/sessions.class.inc @@ -229,7 +229,7 @@ class Sessions extends \NDB_Page $params['SID'] = $this->sessionID; $query = 'SELECT pf.PhysiologicalFileID - FROM + FROM physiological_file pf '; if ($outputType != 'all_types') { @@ -583,7 +583,6 @@ class Sessions extends \NDB_Page // Metadata $queries = [ - 'physiological_electrode' => 'physiological_electrode_file', 'physiological_channel' => 'physiological_channel_file', 'physiological_event_archive' => 'physiological_event_files', 'physiological_annotation_archive' => 'physiological_annotation_files', @@ -616,6 +615,7 @@ class Sessions extends \NDB_Page $query_statement, ['PFID' => $physioFileID] ); + if ($query_statement) { $downloadLinks[$query_value] = [ 'file' => $query_statement['FilePath'], @@ -629,6 +629,28 @@ class Sessions extends \NDB_Page } } + // Electrodes + $file_name = 'physiological_electrode_file'; + // TODO: If we plan to support multiple electrode spaces + // the LIMIT logic should be revisited + $query_statement = "SELECT DISTINCT(FilePath) + FROM physiological_electrode + JOIN physiological_coord_system_electrode_rel + USING (PhysiologicalElectrodeID) + WHERE PhysiologicalFileID=:PFID + LIMIT 1"; + $query_statement = $db->pselect( + $query_statement, + ['PFID' => $physioFileID] + ); + + $downloadLinks[$file_name] = [ + 'file' => '', + 'label' => $labels[$file_name], + ]; + if (count($query_statement) > 0) { + $downloadLinks[$file_name]['file'] = $query_statement[0]['FilePath']; + } return $downloadLinks; }