diff --git a/python/eeg2bids.py b/python/eeg2bids.py index aef0b54..c509fd9 100644 --- a/python/eeg2bids.py +++ b/python/eeg2bids.py @@ -14,7 +14,7 @@ import json # EEG2BIDS Wizard version -appVersion = '1.0.1' +appVersion = '1.0.4' # LORIS credentials of user lorisCredentials = { @@ -124,8 +124,6 @@ def create_candidate_and_visit(sid, data): data['site'], ) - print(new_candidate) - if new_candidate['CandID']: print('create_visit') loris_api.create_visit(new_candidate['CandID'], data['visit'], data['site'], data['project'], @@ -215,10 +213,13 @@ def get_bids_metadata(sid, data): with open(data['file_path']) as fd: try: metadata = json.load(fd) - diff = list(set(metadata.keys()) - set(metadata_fields[data['modality']])) + empty_values = [k for k in metadata if metadata[k].strip() == ''] + diff = list(set(metadata.keys()) - set(metadata_fields[data['modality']]) - set(empty_values)) + ignored_keys = empty_values + diff + response = { 'metadata': metadata, - 'invalid_keys': diff, + 'ignored_keys': ignored_keys, } except ValueError as e: print(e) diff --git a/python/libs/Modifier.py b/python/libs/Modifier.py index 3a17631..f2409c6 100644 --- a/python/libs/Modifier.py +++ b/python/libs/Modifier.py @@ -79,6 +79,7 @@ def modify_dataset_description_json(self): with open(file_path, "r") as fp: file_data = json.load(fp) file_data['PreparedBy'] = self.data['preparedBy'] + file_data['Eeg2bidsVersion'] = self.data['appVersion'] with open(file_path, "w") as fp: json.dump(file_data, fp, indent=4) @@ -157,9 +158,6 @@ def modify_participants_json(self): }, 'project': { 'Description': "Project of the participant" - }, - 'debug': { - 'Version': self.data['appVersion'] } } json_data.update(user_data) @@ -300,11 +298,11 @@ def modify_eeg_json(self): else: referenceField = 'EGGReference' - file_data[referenceField] = self.data['reference'] + file_data[referenceField] = " ".join(self.data['reference'].split()) - if 'metadata' in self.data['bidsMetadata'] and 'invalid_keys' in self.data['bidsMetadata']: + if 'metadata' in self.data['bidsMetadata'] and 'ignored_keys' in self.data['bidsMetadata']: for key in self.data['bidsMetadata']['metadata']: - if key not in self.data['bidsMetadata']['invalid_keys']: + if key not in self.data['bidsMetadata']['ignored_keys']: file_data[key] = self.data['bidsMetadata']['metadata'][key] with open(file_path, "w") as fp: diff --git a/src/jsx/Configuration.js b/src/jsx/Configuration.js index c5f3beb..1be4e15 100644 --- a/src/jsx/Configuration.js +++ b/src/jsx/Configuration.js @@ -601,7 +601,7 @@ const Configuration = (props) => { const validateRecordingParameters = () => { const result = []; - let invalidKeyFound = false; + let ignoredKeyFound = false; if (!appContext.getFromTask('bidsMetadata')) { return formatWarning('No EEG Parameter metadata file selected'); @@ -620,9 +620,9 @@ const Configuration = (props) => { } const metadata = appContext.getFromTask('bidsMetadata')?.metadata; - const invalidKeys = appContext.getFromTask('bidsMetadata')?.invalid_keys; + const ignoredKeys = appContext.getFromTask('bidsMetadata')?.ignored_keys; - if (!metadata || !invalidKeys || metadata.length < 1) { + if (!metadata || !ignoredKeys || metadata.length < 1) { return formatWarning( 'An error occured while processing ' + 'the recording parameters file selected.', @@ -630,8 +630,8 @@ const Configuration = (props) => { } Object.keys(metadata).map((key) => { - if (invalidKeys.indexOf(key) > -1) { - invalidKeyFound = true; + if (ignoredKeys.indexOf(key) > -1) { + ignoredKeyFound = true; result.push(
{formatWarning(`${key}: ${metadata[key]}`)} @@ -649,12 +649,12 @@ const Configuration = (props) => { } }); - if (invalidKeyFound) { + if (ignoredKeyFound) { result.push(

- Note: if invalid or extra parameters are found - in the .json file, they are ignored. + Note: invalid or extra parameters, as well as + parameters with empty values are ignored.

, ); }