Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
235 commits
Select commit Hold shift + click to select a range
f20df3a
added testset weights
jtsauls Dec 24, 2018
10d5b8f
Merge pull request #87 from jtsauls/unet
jtsauls Dec 24, 2018
1df5a6e
moved files
jtsauls Dec 24, 2018
af180c2
moved files
jtsauls Dec 24, 2018
2a2090d
remvoed matlab foci GUI
jtsauls Dec 24, 2018
7ac7bd8
added average width measure per cell
jtsauls Dec 27, 2018
75cc77b
no longer round tau to minutes
jtsauls Dec 27, 2018
92da571
fixing non int in channel masks
jtsauls Dec 27, 2018
4343e51
commented out int check on channel masks
jtsauls Dec 27, 2018
32909b1
debug
Jan 7, 2019
dca7713
param info
jtsauls Jan 8, 2019
0903bdb
infinity to avoid future bugs
jtsauls Jan 10, 2019
b130f99
formatting
jtsauls Jan 11, 2019
587a9fe
Added channel picking CNN
Jan 14, 2019
bf77e04
More functionality for channel picking CNN.
Jan 14, 2019
a038050
Removed unnecessary weights files
Jan 14, 2019
2b873dc
Updated params_Unet.yaml in yaml_templates to support CNN-based chann…
Jan 14, 2019
57a4444
Updated interactive and static plotting utilities to support CNN-base…
Jan 14, 2019
d03200d
Changed aux to misc for windows compatability
Jan 15, 2019
943d826
added mm3_metamorphToTIFF.py
Jan 16, 2019
fe013b8
revert back to aux instead of misc
Jan 16, 2019
49e716f
Added multi-fov support and HDF5 support for Unet
Jan 18, 2019
5d68c94
Merge pull request #89 from jwschroeder3/unet
Jan 18, 2019
8ce8443
Fixed bug in writing of specs.yaml file.
Jan 21, 2019
1b9d378
Fixed bug in writing of specs.yaml file.
Jan 21, 2019
98da719
Merge pull request #90 from jwschroeder3/unet
Jan 21, 2019
a4586b1
debugged minor issue with mm3_Compile.py when using Unet
Jan 22, 2019
93e0137
Merge pull request #91 from jwschroeder3/unet
Jan 22, 2019
a313eef
minor change to peak finder
jtsauls Jan 22, 2019
c7f9de7
fixed conflicts
jtsauls Jan 22, 2019
7790f05
formatting
jtsauls Jan 23, 2019
0d9b161
added appropriate yaml_template file
Jan 24, 2019
399afd7
Merge pull request #92 from jwschroeder3/unet
Jan 24, 2019
c05c79a
param update
jtsauls Jan 25, 2019
558a5ba
constant padding mode, segmentation clean up functions
jtsauls Jan 25, 2019
167f80b
changed logic for what to do in channel picker re identifying channels
jtsauls Jan 27, 2019
3d87e8f
hot fix comment out
jtsauls Feb 4, 2019
5f897f0
reverse, use dev-unet
jtsauls Feb 4, 2019
87200ec
default specs to -1
jtsauls Feb 7, 2019
8b27ac0
support for image trimming for unet segmentaiton
jtsauls Feb 7, 2019
2feec2c
parameter directions
jtsauls Feb 12, 2019
7b3af87
change prediction output to max to 100 rather than 255
jtsauls Feb 14, 2019
8d04f9d
support for hyphens in -o fov selection
jtsauls Feb 18, 2019
c457fb0
support for hyphens in -o fov selection
jtsauls Feb 18, 2019
90701d0
Added functionality for CNN-aided training data generation.
Feb 19, 2019
286dc37
Merge pull request #96 from jwschroeder3/unet
Feb 19, 2019
2acbff4
surpress warnings option
jtsauls Feb 25, 2019
f3317eb
Merge branch 'unet' of https://github.com/junlabucsd/mm3 into unet
jtsauls Feb 27, 2019
6311ee5
fixed merge conflicts
jtsauls Feb 27, 2019
f108666
reflect mode on to constant
jtsauls Feb 27, 2019
65340e1
functionality for saving nonbinary unet predictions
jtsauls Feb 27, 2019
c36831a
untested fix in __data_generation for *self.dim syntax
jtsauls Feb 28, 2019
0fafde8
debugging CNN channel finding
jtsauls Feb 28, 2019
70ca86e
format
jtsauls Feb 28, 2019
5549a9f
Merge pull request #98 from jtsauls/unet
jtsauls Feb 28, 2019
110c45b
channel mask file is now yaml. Included support for t_start in compile
jtsauls Feb 28, 2019
7dfa00a
channel mask file is now yaml. Included support for t_start in compile
jtsauls Feb 28, 2019
163dc3d
time table to .yaml
jtsauls Feb 28, 2019
b84551b
Added GUI
Feb 28, 2019
08294f0
resolved conflict
Feb 28, 2019
ec61819
Merge pull request #100 from jwschroeder3/unet
Feb 28, 2019
ba56b1c
Removed old GUI stuff from mm3_helpers.py
Feb 28, 2019
c872947
Add t_start to mm3_Compile.py
Feb 28, 2019
400277b
Merge pull request #101 from jwschroeder3/unet
Feb 28, 2019
969e782
merged in PR #101
jtsauls Mar 1, 2019
f5fe8ad
safer parameter loading t_start/t_end
jtsauls Mar 1, 2019
c8f8e82
Fix bug in output file naming for GUI
Mar 1, 2019
1bc596d
Merge pull request #102 from jwschroeder3/unet
Mar 1, 2019
e5aeb19
Fixed major phase image saving bug in GUI
Mar 1, 2019
33f73db
Merge pull request #104 from jwschroeder3/unet
Mar 1, 2019
928375e
cleaning up
jtsauls Mar 2, 2019
4ab50d0
numpy floats for new time table when calculating tau
jtsauls Mar 3, 2019
f784aa3
first added docker files
jtsauls Mar 4, 2019
8b732b2
cell object .pkls saved with protocol 2 instead of HIGHEST_PROTOCOL
jtsauls Mar 4, 2019
86a432d
GUI loads re-annotated masks if they exist instead of showing old mask
Mar 4, 2019
5bd6e08
Merge pull request #106 from jwschroeder3/unet
Mar 4, 2019
145faee
changed protocol 2 back to HIGHEST_PROTOCOL
jtsauls Mar 5, 2019
abae01d
pickle.HIGHEST_PROTOCOL
jtsauls Mar 5, 2019
6b433bc
docker file updates
jtsauls Mar 5, 2019
03829ca
docker files
jtsauls Mar 5, 2019
46b2dec
docker file additions
jtsauls Mar 6, 2019
af643cc
plots from dev-plots
jtsauls Mar 6, 2019
3c449c0
added poleage calculation
jtsauls Mar 6, 2019
274ace6
profile analysis fix
jtsauls Mar 6, 2019
5fc160a
docker files and guide
jtsauls Mar 7, 2019
fd8cff5
bug fixes while testing
jtsauls Mar 7, 2019
7b6eb6b
Merge branch 'unet' into dev-unet
jtsauls Mar 7, 2019
3f19a71
moviemaker fixes for docker container
jtsauls Mar 8, 2019
755ed56
Merge pull request #107 from jtsauls/unet
jtsauls Mar 8, 2019
a19d443
fixed flag logic
jtsauls Mar 8, 2019
94f93c5
fix image interval for movie editing
jtsauls Mar 8, 2019
6a5cb4d
foci analysis py3 fixes
jtsauls Mar 11, 2019
ea6324b
py3 support
jtsauls Mar 12, 2019
dd33ab2
-p option necessary?
jtsauls Mar 12, 2019
ae80d89
plotting bug fixes
jtsauls Mar 14, 2019
d834c26
plot update
jtsauls Mar 15, 2019
0cf5ced
Fixed mm3_Compile bug for images with fewer than three imaging channels.
Mar 26, 2019
dc9d2c5
Merge pull request #108 from jwschroeder3/unet
Mar 26, 2019
359aa68
plotting
jtsauls Mar 29, 2019
b857150
Reworked channel picking to use semantic segmentation of cells
Apr 11, 2019
af5770a
Merge pull request #109 from jwschroeder3/unet
Apr 11, 2019
f67f796
Make channel picker with do_seg more efficient
Apr 12, 2019
33472df
Merge pull request #110 from jwschroeder3/unet
Apr 12, 2019
5ec6b8b
Quick bug fix for mm3_Commit.py
Apr 16, 2019
0ab86b7
Merge pull request #111 from jwschroeder3/unet
Apr 16, 2019
13f4dbb
Initial work on tracking training data gui
Apr 17, 2019
bb5c78e
Merge pull request #112 from jwschroeder3/unet
Apr 17, 2019
c71f46e
more tracking gui work
Apr 19, 2019
961b942
Merge pull request #113 from jwschroeder3/unet
Apr 19, 2019
5c27ecc
bunch of plotting things
jtsauls Apr 23, 2019
2abeb8c
Merge pull request #114 from jtsauls/unet
jtsauls Apr 23, 2019
3a6ffb4
merged in new changes and fixed conflicts
jtsauls Apr 23, 2019
e0650d1
Plot events from existing tracking data in track GUI
Apr 24, 2019
68a77de
Plot events from existing tracking data in track GUI
Apr 24, 2019
e05dcc8
Merge pull request #115 from jwschroeder3/unet
Apr 24, 2019
7f355a8
Yet another tracking gui update
Apr 25, 2019
5599510
Merge pull request #116 from jwschroeder3/unet
Apr 25, 2019
063c916
Re-code tracking gui to initialize with all frames/cells as qgraphics…
Apr 26, 2019
67f7692
Tracking GUI works okay now. Several bugs need worked out, including …
Apr 26, 2019
4154233
Merge pull request #117 from jwschroeder3/unet
Apr 26, 2019
3c49c30
Fixed bug in advancing trap/fov in tracking gui
Apr 29, 2019
4963b46
Merge pull request #118 from jwschroeder3/unet
Apr 29, 2019
7627018
track updates
Apr 29, 2019
6ad01ad
Enabled mouse wheel zooming when ctrl is clicked and panning with alt…
Apr 30, 2019
4b1f9ad
Merge pull request #120 from jwschroeder3/unet
Apr 30, 2019
bb955e6
Added support for false joins of distinct cells into single regions
May 2, 2019
ff46d58
Merge pull request #121 from jwschroeder3/unet
May 2, 2019
0d0bb30
Track GUI for training data curation.
May 7, 2019
13962d2
Track GUI for training data curation.
May 7, 2019
670ed72
Merge pull request #122 from jwschroeder3/unet
May 7, 2019
2f35f40
track gui
May 7, 2019
110bfbd
Merge pull request #123 from jwschroeder3/unet
May 7, 2019
661a8e9
note in track_gui
May 9, 2019
6674da1
Added segmentation model with dropout and normalization.
May 13, 2019
13092dc
Merge pull request #124 from jwschroeder3/unet
May 14, 2019
2e2c29b
Allow migration line to be drawn over multiple frames at once.
May 15, 2019
9c7de10
Bug fix in migration line spanning multiple timepoints.
May 15, 2019
60995f4
More tracking GUI updates
May 15, 2019
dfb6916
more updates to tracking gui
Jun 21, 2019
d5ba718
plotting changes
jtsauls Aug 7, 2019
e84b5d2
tracking algorithm and focus detection
Aug 13, 2019
aa56ad9
lots of changes since last push
Aug 27, 2019
1d966c3
mm3.find_all_cell_intensities
Aug 27, 2019
7565372
segmentation markup GUI sizing issues
jtsauls Aug 30, 2019
9837093
support for trimming big images before unet segmentation
jtsauls Sep 3, 2019
dfaa621
updated focus analysis
Sep 3, 2019
7671751
filtering functions
jtsauls Sep 5, 2019
88d8dba
plotting
jtsauls Sep 6, 2019
f87c358
focus tracking improvements
Sep 6, 2019
3ba67e9
Merge branch 'unet' into dev-unet
jtsauls Sep 6, 2019
b6ee391
Merge pull request #126 from jtsauls/dev-unet
jtsauls Sep 6, 2019
929cc44
Merge pull request #127 from junlabucsd/unet
jtsauls Sep 6, 2019
94de970
Updates to focus tracking and reporting
Sep 9, 2019
bed003b
updates to focus analysis
Sep 9, 2019
ff03220
__len__ method for Focus class
Sep 10, 2019
8ebb617
Merge branch 'unet' of https://github.com/jwschroeder3/mm3 into unet
Sep 10, 2019
8ba7603
__len__ method for Focus class
Sep 10, 2019
55bac30
Merge branch 'unet' of https://github.com/jwschroeder3/mm3
Sep 10, 2019
5eccd23
cleaning up
Sep 10, 2019
ec1c8c0
syntax error and sklearn added
jtsauls Sep 12, 2019
c992f2a
parameters update
jtsauls Sep 12, 2019
048f9a0
split otsu threshold from tracking
jtsauls Sep 12, 2019
716a3e7
added standard tracking algorithm as standalone script
jtsauls Sep 12, 2019
cb4c6f3
formatting
jtsauls Sep 12, 2019
b1cefa4
remove filters before phase segment
jtsauls Sep 12, 2019
c214f41
standard tracking algorithm
jtsauls Sep 12, 2019
f0e57a5
removed old parameter files
jtsauls Sep 12, 2019
950d1ee
removed plotting and other auxillary files
jtsauls Sep 12, 2019
ddc2831
removed additional auxillary files
jtsauls Sep 12, 2019
a2f6d7a
removed old analysis notebooks
jtsauls Sep 12, 2019
3b2f2f7
added mm3_plots back in as it is used by TrackGUi
jtsauls Sep 12, 2019
fc1d3be
testing tracking GUI
jtsauls Sep 12, 2019
67aa492
Merge branch 'jwschroeder3-master'
jtsauls Sep 12, 2019
6126630
new readme
jtsauls Sep 12, 2019
b15bc5b
Merge pull request #129 from jtsauls/master
jtsauls Sep 12, 2019
4ab5500
minor update to tracking model dictionary
Sep 13, 2019
df94e3c
resolved conflicts
Sep 13, 2019
59a833f
Merge pull request #130 from jwschroeder3/master
Sep 13, 2019
2dabe39
Started working on GUI for focus tracking
Oct 3, 2019
9bccd22
Merge pull request #132 from jwschroeder3/master
Oct 3, 2019
4dd4d62
mm3_ChannelPicker.py
Oct 31, 2019
5a1f2ab
Merge pull request #135 from jwschroeder3/master
Oct 31, 2019
1564da3
fixed segment-unet bug
Nov 5, 2019
7e1388f
Merge pull request #136 from jwschroeder3/master
Nov 5, 2019
608099e
generalized get_img parameter in mm3_curateTrainingData.py
Nov 5, 2019
edf372b
Merge pull request #137 from jwschroeder3/master
Nov 5, 2019
6b0485d
bug fix in CellTrackGUI
Nov 6, 2019
1b201bc
Merge pull request #138 from jwschroeder3/master
Nov 6, 2019
fd33df9
New tracking models
Jan 9, 2020
60a3edc
New tracking models
Jan 9, 2020
9369361
added functionality for chtc
Jan 17, 2020
1541e80
added functionality for chtc
Jan 17, 2020
e2fce9c
some updates for chtc
Jan 17, 2020
e3c9372
some updates for chtc
Jan 17, 2020
d9d65dc
more chtc updates
Jan 21, 2020
76beba0
more chtc updates
Jan 21, 2020
e25db53
updates to GUI
Jan 23, 2020
103d96b
updates to GUI
Jan 23, 2020
acd554b
allowing rotation of traps
Feb 19, 2020
7580860
allowing rotation of traps
Feb 19, 2020
e5e0473
switching mm3_curateTrainingData.py so that it stretches contrast of …
Feb 20, 2020
c3530f0
switching mm3_curateTrainingData.py so that it stretches contrast of …
Feb 20, 2020
9647437
trip
Mar 3, 2020
6930536
trip
Mar 3, 2020
35338b6
cell-centric focus tracking
Jul 30, 2020
a580ea5
cell-centric focus tracking
Jul 30, 2020
7818b6c
focus track
Sep 4, 2020
32c0378
focus track
Sep 4, 2020
958925b
switched to model.predict
Oct 30, 2020
a8a6264
switched to model.predict
Oct 30, 2020
3ff3377
switched to model.predict
Oct 30, 2020
ff7b3a3
switched to model.predict
Oct 30, 2020
09ad749
Merge branch 'master' of https://github.com/jwschroeder3/mm3
Oct 30, 2020
a32fcb7
Merge branch 'master' of https://github.com/jwschroeder3/mm3
Oct 30, 2020
35c20c0
fixing focus tracking
Oct 30, 2020
1bee4f7
fixing focus tracking
Oct 30, 2020
94070f9
fixing focus tracking
Oct 30, 2020
24d4fa8
fixing focus tracking
Oct 30, 2020
f3ff5a6
fixed focus tracking
Oct 31, 2020
7e78002
fixed focus tracking
Oct 31, 2020
80a9951
Merge pull request #1 from jwschroeder3/focus_track
Oct 31, 2020
3435827
Merge pull request #1 from jwschroeder3/focus_track
Oct 31, 2020
5e51f9c
switching focus tracking to deep learning
Nov 4, 2020
ab1c973
switching focus tracking to deep learning
Nov 4, 2020
a6debe2
deep learning workable
Nov 6, 2020
e0f508b
deep learning workable
Nov 6, 2020
18f2e32
deep learning workable
Nov 9, 2020
7b93694
deep learning workable
Nov 9, 2020
ac1f412
deep learning workable
Nov 9, 2020
2935430
updating for Fukang and Leah
Jan 8, 2021
769f22a
renamed aux folder to sup
Jan 14, 2021
473a55e
removed aux directory
Jan 14, 2021
5b4a2ea
What is commit message?
fukangshe Jan 14, 2021
580ea43
And this path needs to be changed as well
fukangshe Jan 14, 2021
12bee4e
Merge pull request #2 from fukangshe/dl_focus_track
Jan 15, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
163 changes: 163 additions & 0 deletions assemble_traps_image.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
#!/usr/bin/env python3
from __future__ import print_function, division
import six

# import modules
import sys
import os
# import time
import inspect
import argparse
import numpy as np
import yaml
from pprint import pprint # for human readable file output
try:
import cPickle as pickle
except:
import pickle
import numpy as np
from scipy.io import savemat
from skimage import io
import skimage
import matplotlib.pyplot as plt

# user modules
# realpath() will make your script run, even if you symlink it
cmd_folder = os.path.realpath(os.path.abspath(
os.path.split(inspect.getfile(inspect.currentframe()))[0]))
if cmd_folder not in sys.path:
sys.path.insert(0, cmd_folder)

# This makes python look for modules in ./external_lib
cmd_subfolder = os.path.realpath(os.path.abspath(
os.path.join(os.path.split(inspect.getfile(
inspect.currentframe()))[0], "external_lib")))
if cmd_subfolder not in sys.path:
sys.path.insert(0, cmd_subfolder)

import mm3_helpers as mm3

if __name__ == "__main__":

# set switches and parameters
parser = argparse.ArgumentParser(prog='python assemble_traps_image.py',
description='Assemble and save images of traps side-by-side.')
parser.add_argument('-f', '--paramfile', type=str,
required=True, help='Yaml file containing parameters.')
parser.add_argument('--frame', required=True, type=int, help="Defines the frame (1-indexed) to be sliced from each stack.")
parser.add_argument('-o', '--fov', type=str,
required=False, help='List of fields of view to analyze. Input "1", "1,2,3", or "1-10", etc.')
parser.add_argument('--cell_segs', action='store_true',
required=False, help='Apply this argument if you would like cell segmentation results in addition to phase images.')
parser.add_argument('--focus_segs', action='store_true',
required=False, help='Apply this argument if you would like focus segmentation results in addition to phase images.')
parser.add_argument('--fluorescent_channels', type=str,
required=False, help='List of channels (as integers) to include in addition to the phase channel.')

namespace = parser.parse_args()

# Load the project parameters file
mm3.information('Loading experiment parameters.')
if namespace.paramfile:
param_file_path = namespace.paramfile
else:
mm3.warning('No param file specified. Using 100X template.')
param_file_path = 'yaml_templates/params_SJ110_100X.yaml'
p = mm3.init_mm3_helpers(param_file_path) # initialized the helper library

if namespace.fov:
if '-' in namespace.fov:
user_spec_fovs = range(int(namespace.fov.split("-")[0]),
int(namespace.fov.split("-")[1])+1)
else:
user_spec_fovs = [int(val) for val in namespace.fov.split(",")]
else:
user_spec_fovs = []

# load specs file
specs = mm3.load_specs()
# print(specs) # for debugging

# make list of FOVs to process (keys of channel_mask file)
fov_id_list = sorted([fov_id for fov_id in specs.keys()])

# remove fovs if the user specified so
if user_spec_fovs:
fov_id_list[:] = [fov for fov in fov_id_list if fov in user_spec_fovs]

peaks_list = [peak_id for peak_id,val in specs[fov_id_list[0]].items() if val == 1]
img_height, img_width = mm3.load_stack(fov_id_list[0], peaks_list[0], color=p['phase_plane'])[0,:,:].shape

# how many images total will we concatenate horizontally?
img_count = 0
for fov_id in fov_id_list:
fov_peak_count = len([peak_id for peak_id,val in specs[fov_id].items() if val == 1])
img_count += fov_peak_count

# placeholder array of img_height, and proper width to hold all pixels from this fov
phase_arr = np.zeros((230,img_width*img_count), 'uint16')

if namespace.cell_segs:
# p['seg_dir'] = 'segmented'
seg_arr = np.zeros((img_230height,img_width*img_count), 'uint16')

if namespace.focus_segs:
# p['foci_seg_dir'] = 'segmented_foci'
focus_arr = np.zeros((230,img_width*img_count), 'uint16')

if namespace.fluorescent_channels:
fluor_arrays = {}
for fluorescent_channel in namespace.fluorescent_channels:
fluor_arrays[fluorescent_channel] = np.zeros((230,img_width*img_count), 'uint16')

frame = namespace.frame
frame_idx = frame - 1

img_counter = 0
for fov_id in fov_id_list:

print("concatenating images from fov_id {}.".format(fov_id))
peaks_list = [peak_id for peak_id,val in specs[fov_id].items() if val == 1]

for i,peak_id in enumerate(peaks_list):

start_x = img_counter * img_width
end_x = start_x + img_width

if namespace.cell_segs:
# set segmentation image name for saving and loading segmented images
img = mm3.load_stack(fov_id, peak_id, color='seg_unet')[frame_idx,:230,:]
seg_arr[:,start_x:end_x] = img

if namespace.focus_segs:
# set segmentation image name for saving and loading segmented images
img = mm3.load_stack(fov_id, peak_id, color='foci_seg_unet')[frame_idx,:230,:]
focus_arr[:,start_x:end_x] = img

if namespace.fluorescent_channels:
for fluorescent_channel in namespace.fluorescent_channels:
img = mm3.load_stack(fov_id, peak_id, color='c{}'.format(fluorescent_channel))[frame_idx,:230,:]
fluor_arrays[fluorescent_channel][:,start_x:end_x] = img

# now for the phase images
img = mm3.load_stack(fov_id, peak_id, color=p['phase_plane'])[frame_idx,:230,:]
phase_arr[:,start_x:end_x] = img

img_counter += 1

fname = os.path.join(p['experiment_directory'], '{}_t{:0=4}_combined_phase_peaks.png'.format(p['experiment_name'], frame))
io.imsave(fname, skimage.img_as_ubyte(phase_arr))

if namespace.cell_segs:
fname = os.path.join(p['experiment_directory'], '{}_t{:0=4}_combined_cell_seg_peaks.png'.format(p['experiment_name'], frame))
io.imsave(fname, skimage.img_as_ubyte(seg_arr))

if namespace.focus_segs:
fname = os.path.join(p['experiment_directory'], '{}_t{:0=4}_combined_focus_seg_peaks.png'.format(p['experiment_name'], frame))
io.imsave(fname, skimage.img_as_ubyte(focus_arr))

if namespace.fluorescent_channels:
for fluorescent_channel in namespace.fluorescent_channels:
fname = os.path.join(p['experiment_directory'], '{}_t{:0=4}_combined_c{}_peaks.png'.format(p['experiment_name'], frame, fluorescent_channel))
io.imsave(fname, fluor_arrays[fluorescent_channel])

86 changes: 86 additions & 0 deletions combine_tracks_from_chtc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#!/usr/bin/env python3

# import modules
import sys
import os
import inspect
import glob
import argparse
import skimage
from skimage import measure, io
from pprint import pprint # for human readable file output
try:
import cPickle as pickle
except:
import pickle

# user modules
# realpath() will make your script run, even if you symlink it
cmd_folder = os.path.realpath(os.path.abspath(
os.path.split(inspect.getfile(inspect.currentframe()))[0]))
if cmd_folder not in sys.path:
sys.path.insert(0, cmd_folder)

# This makes python look for modules in ./external_lib
cmd_subfolder = os.path.realpath(os.path.abspath(
os.path.join(os.path.split(inspect.getfile(
inspect.currentframe()))[0], "external_lib")))
if cmd_subfolder not in sys.path:
sys.path.insert(0, cmd_subfolder)

import mm3_helpers as mm3

#%%
# when using this script as a function and not as a library the following will execute
if __name__ == "__main__":

# set switches and parameters
parser = argparse.ArgumentParser(
prog='python combine_tracks_from_chtc.py',
description='CHTC saves a separate track file for each fov/peak. Here we combine them.'
)
parser.add_argument(
'-f',
'--paramfile',
type=str,
required=True,
help='Yaml file containing parameters.'
)

namespace = parser.parse_args()

# Load the project parameters file
mm3.information('Loading experiment parameters.')
if namespace.paramfile:
param_file_path = namespace.paramfile
else:
mm3.warning('No param file specified. Using 100X template.')
param_file_path = 'yaml_templates/params_SJ110_100X.yaml'
p = mm3.init_mm3_helpers(param_file_path) # initialized the helper library

# Get file names
fnames = glob.glob(os.path.join(p['cell_dir'], "{}*_tracks.pkl".format(p['experiment_name'])))

### Now prune and save the data.
mm3.information("Reading cell data from each file and combining into one.")

tracks = {}

for fname in fnames:
with open(fname, 'rb') as cell_file:
cell_data = pickle.load(cell_file)
os.remove(fname)
tracks.update(cell_data)

with open(p['cell_dir'] + '/all_cells.pkl', 'wb') as cell_file:
pickle.dump(tracks, cell_file, protocol=pickle.HIGHEST_PROTOCOL)

if os.path.isfile(os.path.join(p['cell_dir'], 'complete_cells.pkl')):
os.remove(os.path.join(p['cell_dir'], 'complete_cells.pkl'))

os.symlink(
os.path.join(p['cell_dir'], 'all_cells.pkl'),
os.path.join(p['cell_dir'], 'complete_cells.pkl')
)

mm3.information("Finished curating and saving cell data.")
25 changes: 25 additions & 0 deletions docker/mm3-py3-tf2/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Tensorflow image based on Ubuntu 16.04 with Python 3 and Jupyter
FROM tensorflow/tensorflow:2.1.0-gpu-py3

# update repositories
RUN apt-get update && \
apt -y dist-upgrade

# Choose locales. Set to US.
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y locales
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y tzdata
RUN locale-gen en_US.UTF-8 # en_GB.UTF-8 eu_FR.UTF-8

# set timezone. Set to PST.
RUN rm -f /etc/localtime /etc/timezone && echo "tzdata tzdata/Areas select America" > myfile && echo "tzdata tzdata/Zones/America select Los_Angeles" >> myfile && debconf-set-selections myfile && dpkg-reconfigure -f noninteractive tzdata && rm myfile

# Install minimal packages
RUN apt-get install -y sudo vim less

# install package for mac OSX socket sharing through x11
RUN apt-get install -y libglu1-mesa

# Copy installation script with Python packages into container and execute
COPY install_mm3_dependencies.sh /root/
RUN /bin/bash /root/install_mm3_dependencies.sh
RUN rm -f /root/install_mm3_dependencies.sh
32 changes: 32 additions & 0 deletions docker/mm3-py3-tf2/install_mm3_dependencies.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash

# -y means yes
apt-get install -y python3-tk

echo "Install other packages for imaging and plotting."
apt-get install -y libreadline-dev libsqlite3-dev libbz2-dev libssl-dev
apt-get install -y libblas-dev liblapack-dev libatlas-dev
apt-get install -y libpng-dev libfreetype6-dev tk-dev pkg-config
apt-get install -y ffmpeg

echo "Install additional python packages with pip."
# Note: pip softlinks to pip3
python -m pip install scipy
python -m pip install matplotlib
python -m pip install seaborn
python -m pip install Pillow
python -m pip install scikit-image
python -m pip install pyYAML
python -m pip install pandas
python -m pip install pims_nd2
python -m pip install sklearn
python -m pip install tensorflow-gpu==2.0

# python binding
python -m pip install freetype-py

# PyQt
python -m pip install PyQt5
sudo apt-get -y install python3-pyqt5
sudo apt-get -y install pyqt5-dev-tools
sudo apt-get -y install qttools5-dev-tools
Loading