Skip to content

Commit

Permalink
[EEG] Electrodes query and file download fix (#8478)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
laemtl authored Mar 28, 2023
1 parent 6db4924 commit 0fe247e
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ class DownloadPanel extends Component {
: '/mri/jiv/get_file.php?file=' + download.file
}
target='_blank'
download
style={{
margin: 0,
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,6 @@ const EventManager = ({
(epoch.type == 'Annotation' ? 'annotation ' : '')
+ 'list-group-item list-group-item-action'
}
style={{
position: 'relative',
}}
>
<div
className="epoch-details"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ class ElectrophysioAnnotations

//Insert new files and data into DB
if (empty($annotationFIDs)) {
//Create new annotation files
$this->_createFiles();

//Get new annotation file ID
$annotation_tsv_ID = $db->pselectOne(
Expand All @@ -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
Expand All @@ -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 {
Expand Down Expand Up @@ -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));
Expand Down
26 changes: 24 additions & 2 deletions modules/electrophysiology_browser/php/sessions.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -616,6 +615,7 @@ class Sessions extends \NDB_Page
$query_statement,
['PFID' => $physioFileID]
);

if ($query_statement) {
$downloadLinks[$query_value] = [
'file' => $query_statement['FilePath'],
Expand All @@ -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;
}

Expand Down

0 comments on commit 0fe247e

Please sign in to comment.