Skip to content

Commit

Permalink
V1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianstricker committed Jun 17, 2022
2 parents cdd513f + 1514596 commit 485aa93
Show file tree
Hide file tree
Showing 23 changed files with 7,147 additions and 666 deletions.
15 changes: 14 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,17 @@ Hotfix patch.

- Fixed an exception with mode calculation in some videos.
- Fixed an issue where config file loading depended on current workign directory when running the program.
- Modified log formatting
- Modified log formatting
Date: June 08, 2022 (v1.4)
Region detection now also employs FFT to detect regions exhibiting periodic changes

- Accuracy is now at 95-98%. Classification rate averages at 92%.
- Highly increased performance by vectorizing FFT.
- Added a config.ini.
- Added framework for decision tree to filter wrong values based on qc-parameters. Needs refinement and rigorous testing.
- Added framework for assessment of region detection method. Can compare results against a region ground truth now.
- Enhanced movement detection to pick the longest window without movement.
- Added option to interpolate timestamps instead of generating artificial ones.
- Errors occuring during execution are now noted in the resulting csv.
- Improved expressiveness of output graphs, videos and pictures
- debug flags are always printed
75 changes: 38 additions & 37 deletions cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,58 +19,59 @@
from numpy import isnan as isnan
import pandas as pd

from medaka_bpm import analyse
from medaka_bpm import analyse_directory

LOGGER = logging.getLogger(__name__)

################################## STARTUP SETUP ##################################
try:
# Parse input arguments
args = setup.parse_arguments()
if __name__ == '__main__':
try:
# Parse input arguments
args = setup.parse_arguments()

experiment_id, args = setup.process_arguments(args, is_cluster_node=True)
experiment_id, args = setup.process_arguments(args, is_cluster_node=True)

# Should receive only a single channel/loop/wellID, it's a cluster node with 1 job.
# Needed as list though
channels = list(args.channels)
loops = list(args.loops)
# Should receive only a single channel/loop/wellID, it's a cluster node with 1 job.
# Needed as list though
channels = list(args.channels)
loops = list(args.loops)

tmp_dir = os.path.join(args.outdir, 'tmp')
tmp_dir = os.path.join(args.outdir, 'tmp')

if args.lsf_index[0] == '\\':
# this is for fixing a weird behaviour: the lsf_index comes with a "\" as the first character. The "\" is usefull to pass the parameter, but need to be deleted here.
args.lsf_index = args.lsf_index[1:]
if args.lsf_index[0] == '\\':
# this is for fixing a weird behaviour: the lsf_index comes with a "\" as the first character. The "\" is usefull to pass the parameter, but need to be deleted here.
args.lsf_index = args.lsf_index[1:]

well_id = 'WE00' + '{:03d}'.format(int(args.lsf_index))
analysis_id = channels[0] + '-' + loops[0] + '-' + well_id
well_id = 'WE00' + '{:03d}'.format(int(args.lsf_index))
analysis_id = channels[0] + '-' + loops[0] + '-' + well_id

# Check if video for well id exists before producting data.
if not io_operations.well_video_exists(args.indir, channels[0], loops[0], well_id):
sys.exit()
# Check if video for well id exists before producting data.
if not io_operations.well_video_exists(args.indir, channels[0], loops[0], well_id):
sys.exit()

setup.config_logger(tmp_dir, (analysis_id + ".log"), args.debug)
setup.config_logger(tmp_dir, (analysis_id + ".log"), args.debug)

# Run analysisp
well_nr = int(well_id[-2:])
results = analyse(args, channels, loops, wells=[well_nr])
# Run analysisp
well_nr = int(well_id[-3:])
results = analyse_directory(args, channels, loops, wells=[well_nr])

# write bpm in tmp directory
out_string = ""
for col in results.columns:
value = results[col][0]
# write bpm in tmp directory
out_string = ""
for col in results.columns:
value = results[col][0]

if not pd.isnull(value):
value = str(value)
else:
value = 'NA'
if not pd.isnull(value):
value = str(value)
else:
value = 'NA'

out_string += f"{col}:{value};"
out_string += f"{col}:{value};"

out_string = out_string[:-1]
out_string = out_string[:-1]

out_file = os.path.join(tmp_dir, (analysis_id + '.txt'))
with open(out_file, 'w') as output:
output.write(out_string)
out_file = os.path.join(tmp_dir, (analysis_id + '.txt'))
with open(out_file, 'w') as output:
output.write(out_string)

except Exception as e:
LOGGER.exception("In analysis dispatched to a cluster node")
except Exception as e:
LOGGER.exception("In analysis dispatched to a cluster node")
10 changes: 8 additions & 2 deletions config.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
[DEFAULT]
VERSION=v1.3.1(apr22)
MaxParallelDirs=1
VERSION = v1.4
MAX_PARALLEL_DIRS = 5
DECISION_TREE_PATH = data/decision_tree.sav

[ANALYSIS]
MIN_BPM = 20
MAX_BPM = 310
ARTIFICIAL_TIMESTAMPS = yes
Binary file added data/decision_tree.sav
Binary file not shown.
Loading

0 comments on commit 485aa93

Please sign in to comment.