99 :copyright: Copyright (c) 2016-2019 Jungmann Lab, MPI of Biochemistry
1010"""
1111import os .path
12+ from . import __version__
1213
1314
1415def picasso_logo ():
@@ -137,7 +138,7 @@ def _csv2hdf(path, pixelsize):
137138 locs .sort (kind = "mergesort" , order = "frame" )
138139
139140 img_info = {}
140- img_info ["Generated by" ] = "Picasso csv2hdf"
141+ img_info ["Generated by" ] = f "Picasso v { __version__ } csv2hdf"
141142 img_info ["Frames" ] = int (_np .max (frames )) + 1
142143 img_info ["Height" ] = int (_np .ceil (_np .max (y )))
143144 img_info ["Width" ] = int (_np .ceil (_np .max (x )))
@@ -203,7 +204,7 @@ def _link(files, d_max, tolerance):
203204 link_info = {
204205 "Maximum Distance" : d_max ,
205206 "Maximum Transient Dark Time" : tolerance ,
206- "Generated by" : "Picasso Link" ,
207+ "Generated by" : f "Picasso v { __version__ } Link" ,
207208 }
208209 info .append (link_info )
209210 io .save_locs (base + "_link.hdf5" , linked_locs , info )
@@ -268,7 +269,7 @@ def _cluster_combine(files):
268269 continue
269270 combined_locs = postprocess .cluster_combine (locs )
270271 base , ext = os .path .splitext (path )
271- combined_info = {"Generated by" : "Picasso Combine" }
272+ combined_info = {"Generated by" : f "Picasso v { __version__ } Combine" }
272273 info .append (combined_info )
273274 io .save_locs (base + "_comb.hdf5" , combined_locs , info )
274275
@@ -287,7 +288,7 @@ def _cluster_combine_dist(files):
287288 continue
288289 combinedist_locs = postprocess .cluster_combine_dist (locs )
289290 base , ext = os .path .splitext (path )
290- cluster_combine_dist_info = {"Generated by" : "Picasso Combineidst" }
291+ cluster_combine_dist_info = {"Generated by" : f "Picasso v { __version__ } Combineidst" }
291292 info .append (cluster_combine_dist_info )
292293 io .save_locs (base + "_cdist.hdf5" , combinedist_locs , info )
293294
@@ -329,7 +330,7 @@ def _clusterfilter(files, clusterfile, parameter, minval, maxval):
329330
330331 base , ext = os .path .splitext (path )
331332 clusterfilter_info = {
332- "Generated by" : "Picasso Clusterfilter - in" ,
333+ "Generated by" : f "Picasso v { __version__ } Clusterfilter - in" ,
333334 "Paramter" : parameter ,
334335 "Minval" : minval ,
335336 "Maxval" : maxval ,
@@ -353,7 +354,7 @@ def _clusterfilter(files, clusterfile, parameter, minval, maxval):
353354
354355 base , ext = os .path .splitext (path )
355356 clusterfilter_info = {
356- "Generated by" : "Picasso Clusterfilter - out" ,
357+ "Generated by" : f "Picasso v { __version__ } Clusterfilter - out" ,
357358 "Paramter" : parameter ,
358359 "Minval" : minval ,
359360 "Maxval" : maxval ,
@@ -375,7 +376,7 @@ def _undrift(files, segmentation, display=True, fromfile=None):
375376 from numpy import genfromtxt , savetxt
376377
377378 paths = glob .glob (files )
378- undrift_info = {"Generated by" : "Picasso Undrift" }
379+ undrift_info = {"Generated by" : f "Picasso v { __version__ } Undrift" }
379380 if fromfile is not None :
380381 undrift_info ["From File" ] = fromfile
381382 drift = genfromtxt (fromfile )
@@ -457,7 +458,7 @@ def _density(files, radius):
457458 locs = postprocess .compute_local_density (locs , info , radius )
458459 base , ext = os .path .splitext (path )
459460 density_info = {
460- "Generated by" : "Picasso Density" ,
461+ "Generated by" : f "Picasso v { __version__ } Density" ,
461462 "Radius" : radius ,
462463 }
463464 info .append (density_info )
@@ -478,7 +479,7 @@ def _dbscan(files, radius, min_density, pixelsize=None):
478479 clusters = clusterer .find_cluster_centers (locs , pixelsize )
479480 base , _ = os .path .splitext (path )
480481 dbscan_info = {
481- "Generated by" : "Picasso DBSCAN" ,
482+ "Generated by" : f "Picasso v { __version__ } DBSCAN" ,
482483 "Radius" : radius ,
483484 "Minimum local density" : min_density ,
484485 }
@@ -506,7 +507,7 @@ def _hdbscan(files, min_cluster, min_samples, pixelsize=None):
506507 clusters = clusterer .find_cluster_centers (locs , pixelsize )
507508 base , ext = os .path .splitext (path )
508509 hdbscan_info = {
509- "Generated by" : "Picasso HDBSCAN" ,
510+ "Generated by" : f "Picasso v { __version__ } HDBSCAN" ,
510511 "Min. cluster" : min_cluster ,
511512 "Min. samples" : min_samples ,
512513 }
@@ -540,7 +541,7 @@ def _smlm_clusterer(
540541 clusters = clusterer .find_cluster_centers (locs , pixelsize )
541542 base , ext = os .path .splitext (path )
542543 smlm_cluster_info = {
543- "Generated by" : "Picasso SMLM clusterer" ,
544+ "Generated by" : f "Picasso v { __version__ } SMLM clusterer" ,
544545 "Radius_xy" : radius ,
545546 "Radius_z" : radius_z ,
546547 "Min locs" : min_locs ,
@@ -590,7 +591,7 @@ def _dark(files):
590591 locs , info = io .load_locs (path )
591592 locs = postprocess .compute_dark_times (locs )
592593 base , ext = os .path .splitext (path )
593- d_info = {"Generated by" : "Picasso Dark" }
594+ d_info = {"Generated by" : f "Picasso v { __version__ } Dark" }
594595 info .append (d_info )
595596 io .save_locs (base + "_dark.hdf5" , locs , info )
596597
@@ -610,7 +611,7 @@ def _align(files, display):
610611 locs = [_ [0 ] for _ in locs_infos ]
611612 infos = [_ [1 ] for _ in locs_infos ]
612613 aligned_locs = align (locs , infos , display = display )
613- align_info = {"Generated by" : "Picasso Align" , "Files" : files }
614+ align_info = {"Generated by" : f "Picasso v { __version__ } Align" , "Files" : files }
614615 for file , locs_ , info in zip (files , aligned_locs , infos ):
615616 info .append (align_info )
616617 base , ext = splitext (file )
@@ -625,7 +626,7 @@ def _join(files, keep_index=True):
625626
626627 locs , info = load_locs (files [0 ])
627628 total_frames = info [0 ]["Frames" ]
628- join_info = {"Generated by" : "Picasso Join" , "Files" : [files [0 ]]}
629+ join_info = {"Generated by" : f "Picasso v { __version__ } Join" , "Files" : [files [0 ]]}
629630 for path in files [1 :]:
630631 locs_ , info_ = load_locs (path )
631632 try :
@@ -977,7 +978,7 @@ def prompt_info():
977978 px = None
978979
979980 localize_info = {
980- "Generated by" : "Picasso Localize" ,
981+ "Generated by" : f "Picasso v { __version__ } Localize" ,
981982 "ROI" : None , #TODO: change if ROI is given
982983 "Box Size" : box ,
983984 "Min. Net Gradient" : min_net_gradient ,
@@ -1477,12 +1478,20 @@ def _spinna_batch_analysis(parameters_filename, asynch=True, bootstrap=False, ve
14771478 nn_counts [f"{ t1 } -{ t2 } " ] = nn_plotted
14781479 mixer .nn_counts = nn_counts
14791480 n_total = sum (n_simulated .values ())
1480- dist_sim = spinna .get_NN_dist_simulated (
1481- mixer .convert_props_to_counts (opt_props [0 ], n_total ),
1482- sim_repeats ,
1483- mixer ,
1484- duplicate = True ,
1485- )
1481+ if isinstance (opt_props , tuple ):
1482+ dist_sim = spinna .get_NN_dist_simulated (
1483+ mixer .convert_props_to_counts (opt_props [0 ], n_total ),
1484+ sim_repeats ,
1485+ mixer ,
1486+ duplicate = True ,
1487+ )
1488+ else :
1489+ dist_sim = spinna .get_NN_dist_simulated (
1490+ mixer .convert_props_to_counts (opt_props , n_total ),
1491+ sim_repeats ,
1492+ mixer ,
1493+ duplicate = True ,
1494+ )
14861495 for i , (t1 , t2 , _ ) in enumerate (mixer .get_neighbor_idx (duplicate = True )):
14871496 fig , ax = spinna .plot_NN (
14881497 dist = dist_sim [i ], mode = 'plot' , show_legend = False ,
0 commit comments