Skip to content

Commit

Permalink
nemar.json file
Browse files Browse the repository at this point in the history
  • Loading branch information
dungscout96 committed Oct 3, 2023
1 parent 79527dc commit cac0150
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 2 deletions.
12 changes: 11 additions & 1 deletion run_pipeline.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,29 @@ function run_pipeline(dsnumber, varargin)

eeg_logdir = fullfile(opt.logdir, 'eeg_logs');
log_file = fullfile(opt.logdir, 'matlab_log');
codeDir = fullfile(opt.logdir, "code");
codeDir = fullfile(opt.outputdir, "code");
if strcmp(opt.modeval, "new")
% create output directories
if opt.verbose
fprintf('Output dir: %s\n', opt.outputdir);
end
if exist(opt.outputdir, 'dir')
if exist(codeDir, 'dir') && exist(fullfile(codeDir, 'nemar.json'))
if ~exist(fullfile(pipelineroot, 'temp-nemar-json'), 'dir')
mkdir(fullfile(pipelineroot, 'temp-nemar-json'));
end
[status, msg] = copyfile(fullfile(codeDir, 'nemar.json'), fullfile(pipelineroot, 'temp-nemar-json', [dsnumber '_nemar.json']))
if status ~= 1
error('Error backing up nemar.json file');
end
end
rmdir(opt.outputdir, 's');
end
status = mkdir(opt.outputdir);
if ~status
error('Could not create output directory');
else
status = copyfile(fullfile(pipelineroot, 'temp-nemar-json', [dsnumber '_nemar.json'], fullfile(codeDir, 'nemar.json')));
disp("Output directory created");
end

Expand Down
30 changes: 29 additions & 1 deletion web/aggregate_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import argparse
import subprocess
import re
import json

raw_dir = "/data/qumulo/openneuro"
processed_dir = "/data/qumulo/openneuro/processed"
Expand Down Expand Up @@ -38,6 +39,31 @@ def get_known_errors(matlab_log, batcherr_log):

return errors

def write_nemar_json(df, is_processed):
path = os.path.join(processed_dir, df['dsnumber'][0])
code_dir = path + '/code'
if not os.path.exists(code_dir):
os.mkdir(code_dir)

status_file = code_dir + "/nemar.json"
if os.path.exists(status_file):
with open(status_file, 'r') as fin:
status = json.load(fin)
else:
status = {
"error": "",
"warning": "",
"has_visualization": None,
}
status["has_visualization"] = is_processed
with open(status_file, 'w') as fout:
json.dump(status, fout, indent=4)
try:
os.chmod(status_file, 0o664) # add write permission to group
except:
print(f'Cannot change permission for {status_file}')


def append_modality(df):
'''
Get the modality of the dataset
Expand Down Expand Up @@ -103,6 +129,8 @@ def append_debug(df, processing):
except:
print(f'Cannot change permission for {debug_note}')
df['debug_note'] = notes
# write nemar.json with processed status based on value of notes
write_nemar_json(df, is_processed=(notes == "ok"))

# manual debug note
manual_debug_note = os.path.join(path, "logs", "debug", "manual_debug_note")
Expand Down Expand Up @@ -300,4 +328,4 @@ def get_pipeline_status(dsnumbers):
final_df.to_html(out, index=False, na_rep="")
logfile.write('writing html\n')

logfile.close()
logfile.close()
6 changes: 6 additions & 0 deletions web/pipeline_status.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@
<input class="form-control" id="sbatch" name="sbatch"></input>
<button type="button" onclick="copyText('sbatch')">Copy path</button>
</div>
<div class="form-group">
<label for="doc" class="col-form-label">nemar.json:</label>
<input class="form-control" id="nemarjson" name="nemarjson"></input>
<button type="button" onclick="copyText('nemarjson')">Copy path</button>
</div>
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
</form>
</div>
Expand Down Expand Up @@ -179,6 +184,7 @@
modal.find('#indLogDir').val('/expanse/projects/nemar/openneuro/processed/' + dsnumber + '/logs/eeg_logs');
modal.find('#note').val('/expanse/projects/nemar/openneuro/processed/' + dsnumber + '/logs/debug/manual_debug_note');
modal.find('#sbatch').val('/expanse/projects/nemar/openneuro/processed/logs/' + dsnumber + 'sbatch');
modal.find('#nemarjson').val('/expanse/projects/nemar/openneuro/processed/' + dsnumber + '/code/nemar.json');
});
$('#dsMatlabLogs').on('show.bs.modal', function (event) {
var clicked = $(event.relatedTarget);
Expand Down

0 comments on commit cac0150

Please sign in to comment.