Skip to content

Commit

Permalink
Add username and date in metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeTh committed Jun 25, 2020
1 parent 188d9c8 commit 74a09e5
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 25 deletions.
1 change: 1 addition & 0 deletions dmriqcpy/analysis/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def stats_mean_median(column_names, filenames):
across subjects.
"""
values = []
import time
for filename in filenames:
data = nib.load(filename).get_data()
shape = data.shape
Expand Down
10 changes: 8 additions & 2 deletions dmriqcpy/template/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,14 @@
<label class="btn w3-light-grey" style="margin: 6px" for="save_file">
<span>Save QC</span>
</label>
<b><span class="w3-bar-item w3-right" style="padding: 12px; color: white;" id="counter"></span></b>
<b><span class="w3-bar-item w3-right" style="padding: 12px; color: white" id="curr_subj"></span></b>
<b>
<span style="position: absolute; left: 50%; padding: 12px; color: white; transform: translate(-50%, 0%)">
<span id="username"></span>
<span id="datetime"></span>
</span>
</b>
<b><span class="w3-right" style="padding: 12px; color: white;" id="counter"></span></b>
<b><span class="w3-right" style="padding: 12px; color: white" id="curr_subj"></span></b>
</div>
</div>
</div>
Expand Down
83 changes: 60 additions & 23 deletions dmriqcpy/template/libs/js/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,8 @@ var zoom = 2;
zoom_activated = false;
help_displayed = false;
qc_saved = true;
person = "";
datetime = "";
nodes = Array.prototype.slice.call(document.getElementById('navigation').children);
currentMetric = document.getElementById("navigation").children[0].innerText.replace(/ /g,"_");
dict_metrics = {};
Expand Down Expand Up @@ -721,6 +723,17 @@ function load_qc(){
}
else if (importedJSON[dict_idx]["type"] == "settings")
{
if (importedJSON[dict_idx]["username"] != null)
{
person = importedJSON[dict_idx]["username"];
document.getElementById("username").innerText = "Username: " + person;
}

if (importedJSON[dict_idx]["date"] != null)
{
datetime = importedJSON[dict_idx]["date"];
document.getElementById("datetime").innerText = "Last save: " + datetime;
}
for (let data_idx in importedJSON[dict_idx]["data"]){
name = importedJSON[dict_idx]["data"][data_idx]["tab_name"];
idx = importedJSON[dict_idx]["data"][data_idx]["tab_index"];
Expand All @@ -737,33 +750,57 @@ function load_qc(){

function save_qc(){
data = [];
settings = {"type": "settings", "data": []};
report = {"type": "report", "data": []};
for (let metrics of document.getElementsByClassName("tab-pane")){
if (metrics.id != "Dashboard"){
curr_tab = {};
curr_tab["tab_name"] = metrics.id;
curr_tab["tab_index"] = dict_metrics[metrics.id];
settings["data"].push(curr_tab);
for (let subject of metrics.getElementsByClassName("tab")){
if (document.getElementById(subject.id + "_status")){
curr_subj = {};
curr_subj["qc"] = metrics.id;
curr_subj["status"] = document.getElementById(subject.id + "_status").innerText;
curr_subj["comments"] = document.getElementById(subject.id + "_comments").value;
curr_subj["filename"] = subject.id;
report["data"].push(curr_subj);
settings = {"type": "settings", "data": [], "username": "", "date": ""};
if (person == null)
{
person = "";
}
if (person != null)
{
person = prompt("Please enter your name", person);
}
while (person == "") {
person = prompt("Please enter your name");
}
if (person != null){
var currentdate = new Date();
var datetime = currentdate.getDate() + "/"
+ (currentdate.getMonth()+1) + "/"
+ currentdate.getFullYear() + " @ "
+ currentdate.getHours() + ":"
+ currentdate.getMinutes() + ":"
+ currentdate.getSeconds();
settings["date"] = datetime;
settings["username"] = person;
document.getElementById("username").innerText = "Username: " + person;
document.getElementById("datetime").innerText = "Last save: " + datetime;
report = {"type": "report", "data": []};
for (let metrics of document.getElementsByClassName("tab-pane")){
if (metrics.id != "Dashboard"){
curr_tab = {};
curr_tab["tab_name"] = metrics.id;
curr_tab["tab_index"] = dict_metrics[metrics.id];
settings["data"].push(curr_tab);
for (let subject of metrics.getElementsByClassName("tab")){
if (document.getElementById(subject.id + "_status")){
curr_subj = {};
curr_subj["qc"] = metrics.id;
curr_subj["status"] = document.getElementById(subject.id + "_status").innerText;
curr_subj["comments"] = document.getElementById(subject.id + "_comments").value;
curr_subj["filename"] = subject.id;
report["data"].push(curr_subj);
}
}
}
}
}

data.push(settings);
data.push(report);
var jsons = JSON.stringify(data);
var blob = new Blob([jsons], {type: "application/json"});
saveAs(blob, "data.json");
qc_saved = true;
data.push(settings);
data.push(report);
var jsons = JSON.stringify(data);
var blob = new Blob([jsons], {type: "application/json"});
saveAs(blob, "data.json");
qc_saved = true;
}
}

function comment_update(){
Expand Down

0 comments on commit 74a09e5

Please sign in to comment.