-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
135 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +0,0 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
|
||
""" | ||
documentation | ||
""" | ||
|
||
if __name__ == '__main__': | ||
pass | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,33 @@ | ||
import sqlite3 | ||
|
||
from MRICenterline.app.database import name_id | ||
from MRICenterline import CFG | ||
|
||
|
||
def get_all_sessions(): | ||
con = sqlite3.connect(CFG.get_db()) | ||
sessions = con.cursor().execute(""" | ||
select session_id, lengths_id, cl_id, timestamp, case_name, name | ||
from sessions | ||
inner join case_list | ||
on case_list.case_id = sessions.case_id | ||
inner join sequences | ||
on sequences.seq_id = sessions.seq_id | ||
""").fetchall() | ||
|
||
sessions_list, case_names, timestamps, seq_names, length, centerline = [], [], [], [], [], [] | ||
for session_id, lengths_id, cl_id, timestamp, case_name, name in sessions: | ||
case_names.append(case_name) | ||
timestamps.append(timestamp) | ||
seq_names.append(name) | ||
sessions_list.append(session_id) | ||
|
||
if lengths_id: | ||
length.append(con.cursor().execute( | ||
f"select count(*) from 'length_coordinates' where lengths_id_id = {lengths_id}").fetchone()[0]) | ||
else: | ||
length.append(0) | ||
|
||
if cl_id: | ||
centerline.append(con.cursor().execute( | ||
f"SELECT count(*) FROM 'centerline_coordinates' where cl_id = {cl_id}").fetchone()[0]) | ||
else: | ||
centerline.append(0) | ||
sessions = con.cursor().execute("select * from 'sessions'").fetchall() | ||
session_table_headers = [i[1] for i in con.cursor().execute("select * from pragma_table_info('sessions');").fetchall()] | ||
|
||
dat = {h: list() for h in session_table_headers} | ||
for s in sessions: | ||
conv = list(s) | ||
conv[5] = name_id.get_sequence_name(s[5], s[6]) | ||
conv[6] = name_id.get_case_name(s[6]) | ||
for (_, li), i in zip(dat.items(), conv): | ||
li.append(i) | ||
|
||
con.close() | ||
|
||
return {"case name": case_names, | ||
"timestamps": timestamps, | ||
"sequence name": seq_names, | ||
'length points': length, | ||
'centerline points': centerline, | ||
'session_id': sessions_list}, len(sessions) | ||
dat.pop('lengths_id') | ||
dat.pop('cl_id') | ||
return dat, len(sessions) | ||
|
||
|
||
def get_latest_sessions(): | ||
pass | ||
# select * from 'sessions' group by case_id order by timestamp desc | ||
pass | ||
|
||
|
||
if __name__ == "__main__": | ||
print(get_all_sessions()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
from .organize_data import run_organize_data | ||
from .time_report import run_time_report | ||
from .run_metadata_sequence_scan import run_metadata_sequence_scan | ||
from .load_v3_points import load_v3_points |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from pathlib import Path | ||
|
||
import logging | ||
logging.getLogger(__name__) | ||
|
||
|
||
def load_v3_points(folder: str or Path): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
|
||
""" | ||
documentation | ||
""" | ||
|
||
if __name__ == '__main__': | ||
pass | ||
from .arg_setup import arg_setup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,40 @@ | ||
from MRICenterline.CommandLineInterface import run_folder_scan | ||
import sys | ||
import argparse | ||
|
||
opts = [opt for opt in sys.argv[1:] if opt.startswith("-")] | ||
args = [arg for arg in sys.argv[1:] if not arg.startswith("-")] | ||
from MRICenterline.app import scanner | ||
|
||
if "-f" in opts: | ||
run_folder_scan(args) | ||
else: | ||
raise SystemError("Please see usage instructions.") | ||
import logging | ||
logging.getLogger(__name__) | ||
|
||
|
||
def arg_setup(): | ||
parser = argparse.ArgumentParser(description='ImageUntangler CLI version') | ||
|
||
parser.add_argument('-f', '--folder', action='store', type=str, | ||
help="Folder to scan", required=True) | ||
|
||
arguments = [ | ||
("-s", "--scan", "Generate sequence/metadata report"), | ||
("-o", "--org", "Organize folder data"), | ||
("-t", "--time", "Generate timing report"), | ||
("-v3", "--ver3", "Load points from v3") | ||
] | ||
|
||
for sh, lo, he in arguments: | ||
parser.add_argument(sh, lo, action='store_true', help=he) | ||
|
||
args = parser.parse_args() | ||
|
||
logging.info(f"Starting scan: {args.folder}") | ||
|
||
# TODO: create a temporary CFG file for the scanner to use | ||
|
||
if args.scan: | ||
logging.info("Generate sequence/metadata report") | ||
if args.org: | ||
logging.info("Organize folder data") | ||
if args.time: | ||
logging.info("Generate timing report") | ||
if args.ver3: | ||
logging.info("Load points from v3") | ||
scanner.run_metadata_sequence_scan(args.folder) | ||
scanner.load_v3_points(args.folder) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.