Skip to content
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

[EEG] EEG uploader module #8409

Merged
merged 7 commits into from
Apr 5, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions SQL/0000-00-01-Modules.sql
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,6 @@ INSERT INTO modules (Name, Active) VALUES ('timepoint_list', 'Y');
INSERT INTO modules (Name, Active) VALUES ('user_accounts', 'Y');
INSERT INTO modules (Name, Active) VALUES ('electrophysiology_browser', 'Y');
INSERT INTO modules (Name, Active) VALUES ('dqt', 'Y');
INSERT INTO modules (Name, Active) VALUES ('electrophysiology_uploader', 'Y');

ALTER TABLE issues ADD CONSTRAINT `fk_issues_7` FOREIGN KEY (`module`) REFERENCES `modules` (`ID`);
4 changes: 3 additions & 1 deletion SQL/0000-00-03-ConfigTables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ INSERT INTO ConfigSettings (Name, Description, Visible, AllowMultiple, DataType,
INSERT INTO ConfigSettings (Name, Description, Visible, AllowMultiple, DataType, Parent, Label, OrderNumber) SELECT 'MINCToolsPath', 'Path to the MINC tools', 1, 0, 'web_path', ID, 'Path to the MINC tools', 12 FROM ConfigSettings WHERE Name="paths";
INSERT INTO ConfigSettings (Name, Description, Visible, AllowMultiple, DataType, Parent, Label, OrderNumber) SELECT 'documentRepositoryPath', 'Path to uploaded document repository files', 1, 0, 'web_path', ID, 'Document Repository Upload Path', 13 FROM ConfigSettings WHERE Name="paths";
INSERT INTO ConfigSettings (Name, Description, Visible, AllowMultiple, DataType, Parent, Label, OrderNumber) SELECT 'dataReleasePath', 'Path to uploaded data release files', 1, 0, 'web_path', ID, 'Data release Upload Path', 14 FROM ConfigSettings WHERE Name="paths";
INSERT INTO ConfigSettings (Name, Description, Visible, AllowMultiple, DataType, Parent, Label, OrderNumber) SELECT 'EEGUploadIncomingPath', 'Path to the upload directory for incoming EEG studies', 1, 0, 'text', ID, 'EEG Incoming Directory', 7 FROM ConfigSettings WHERE Name="paths";



INSERT INTO ConfigSettings (Name, Description, Visible, AllowMultiple, Label, OrderNumber) VALUES ('gui', 'Settings related to the overall display of LORIS', 1, 0, 'GUI', 3);
Expand Down Expand Up @@ -289,4 +291,4 @@ INSERT INTO Config (ConfigID, Value) SELECT ID, '' FROM ConfigSettings WHERE Na
INSERT INTO Config (ConfigID, Value) SELECT ID, '' FROM ConfigSettings WHERE Name='bids_dataset_authors';
INSERT INTO Config (ConfigID, Value) SELECT ID, '' FROM ConfigSettings WHERE Name='bids_acknowledgments_text';
INSERT INTO Config (ConfigID, Value) SELECT ID, '' FROM ConfigSettings WHERE Name='bids_readme_text';
INSERT INTO Config (ConfigID, Value) SELECT ID, '' FROM ConfigSettings WHERE Name='bids_validator_options_to_ignore';
INSERT INTO Config (ConfigID, Value) SELECT ID, '' FROM ConfigSettings WHERE Name='bids_validator_options_to_ignore';
15 changes: 15 additions & 0 deletions SQL/0000-00-05-ElectrophysiologyTables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,21 @@ CREATE TABLE `physiological_annotation_rel` (
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,
`UploadedBy` varchar(255) NOT NULL DEFAULT '',
`UploadDate` DateTime DEFAULT NULL,
`UploadLocation` varchar(255) NOT NULL DEFAULT '',
`Status` enum('Not Started', 'In Progress', 'Complete', 'Failed') DEFAULT 'Not Started',
`SessionID` int(10) unsigned NOT NULL default '0',
`MetaData` TEXT default NULL,
PRIMARY KEY (`UploadID`),
KEY (`SessionID`),
CONSTRAINT `FK_eegupload_SessionID`
FOREIGN KEY (`SessionID`) REFERENCES `session` (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- Insert into physiological_output_type
INSERT INTO physiological_output_type
(`OutputTypeName`, `OutputTypeDescription`)
Expand Down
21 changes: 21 additions & 0 deletions SQL/New_patches/2023-02-24-electrophysiology_uploader.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
-- Create EEG upload table
CREATE TABLE `electrophysiology_uploader` (
`UploadID` int(10) unsigned NOT NULL AUTO_INCREMENT,
`UploadedBy` varchar(255) NOT NULL DEFAULT '',
`UploadDate` DateTime DEFAULT NULL,
`UploadLocation` varchar(255) NOT NULL DEFAULT '',
`Status` enum('Not Started', 'In Progress', 'Complete', 'Failed') DEFAULT 'Not Started',
`SessionID` int(10) unsigned NOT NULL default '0',
`MetaData` TEXT default NULL,
PRIMARY KEY (`UploadID`),
KEY (`SessionID`),
CONSTRAINT `FK_eegupload_SessionID`
FOREIGN KEY (`SessionID`) REFERENCES `session` (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- Add to module table
INSERT INTO modules (Name, Active) VALUES ('electrophysiology_uploader', 'Y');

-- Add new configurations for eeg uploader
INSERT INTO ConfigSettings (Name, Description, Visible, AllowMultiple, DataType, Parent, Label, OrderNumber) SELECT 'EEGUploadIncomingPath', 'Path to the upload directory for incoming EEG studies', 1, 0, 'text', ID, 'EEG Incoming Directory', 7 FROM ConfigSettings WHERE Name="paths";

1 change: 1 addition & 0 deletions modules/electrophysiology_uploader/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
js/*
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
import {useState, useEffect} from 'react';
import PropTypes from 'prop-types';
import Loader from 'jsx/Loader';
import {TabPane, Tabs} from 'jsx/Tabs';
import UploadForm from './UploadForm';
import UploadViewer from './UploadViewer';
import {createRoot} from 'react-dom/client';

/**
* UploadViewer
*
* @param {array} props
* @return {JSX}
*/
export default function ElectrophysiologyUploader(props) {
const [isLoaded, setIsLoaded] = useState(false);
const [data, setData] = useState({});

/**
* Called by React when the component has been rendered on the page.
*/
useEffect(() => {
fetchData();
}, []);

/**
* Retrive data from the provided URL and save it in state
* Additionaly add hiddenHeaders to global loris vairable
* for easy access by columnFormatter.
*/
const fetchData = () => {
fetch(`${props.DataURL}/?format=json`, {
method: 'GET',
}).then((response) => {
if (!response.ok) {
console.error(response.status + ': ' + response.statusText);
return;
}

response.json().then((data) => {
setData(data);
setIsLoaded(true);
});
}).catch((error) => {
console.error(error);
});
};

if (!isLoaded) {
return <Loader />;
}

const tabList = [
{id: 'browse', label: 'Browse'},
{id: 'upload', label: 'Upload'},
];

return (
<Tabs tabs={tabList} defaultTab='browse' updateURL={true}>
<TabPane TabId={tabList[0].id}>
<UploadViewer
data={data.Data}
fieldOptions={data.fieldOptions}
/>
</TabPane>
<TabPane TabId={tabList[1].id}>
<UploadForm
uploadURL={`${props.DataURL}/upload`}
/>
</TabPane>
</Tabs>
);
}

ElectrophysiologyUploader.propTypes = {
DataURL: PropTypes.string.isRequired,
};

/**
* Render imaging_uploader on page load
*/
document.addEventListener('DOMContentLoaded', function() {
const root = createRoot(
document.getElementById('lorisworkspace')
);
root.render(
<ElectrophysiologyUploader
Module='imaging_uploader'
DataURL={loris.BaseURL + '/electrophysiology_uploader'}
/>
);
});
Loading