Created
October 12, 2016 14:24
-
-
Save mutaku/42d1372efb36654a5a652c7a73de0dc4 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
r = rois.all[38] | |
test_mask = copy.copy(r.metrics.flash_mask) #+ [108, 109, 111] | |
print test_mask | |
# Calculate periodicity approximation | |
# Method 1: Select max drop for each cluster | |
# |"```"|` | |
# -*****-* -> 5 points | |
working_mask_m1 = copy.copy(test_mask) | |
working_mask_m1_grouping = [map(operator.itemgetter(1), g) | |
for k, g in groupby(enumerate(working_mask_m1), | |
lambda (i,x):i-x)] | |
working_mask_m1_clusters = [s for i, s in enumerate(working_mask_m1_grouping) | |
if len(s) > 1] | |
for i, cluster in enumerate(working_mask_m1_clusters): | |
vals = [r.metrics.normalized_gfp[x] for x in cluster] | |
cluster.pop(vals.index(max(vals))) | |
working_mask_m1_clusters[i] = cluster | |
working_mask_m1_final = sorted(set(working_mask_m1) \ | |
- set([c for cluster in working_mask_m1_clusters | |
for c in cluster])) | |
working_mask_m1_distances = [i-j for i, j in zip(working_mask_m1_final[1:], | |
working_mask_m1_final[:-1])] | |
# Method 2: Non-drop points between detectable drops | |
# |"```"|` | |
# --***--* -> 3 points | |
working_mask_m2 = copy.copy(test_mask) | |
working_mask_m2_distances = [i-j for i, j in zip(working_mask_m2[1:], | |
working_mask_m2[:-1]) | |
if i-j != 1] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment