@@ -423,6 +423,26 @@ def _undrift(files, segmentation, display=True, fromfile=None):
423423 savetxt (base + "_drift.txt" , drift , header = "dx\t dy" , newline = "\r \n " )
424424
425425
426+ def _undrift_aim (
427+ files , segmentation , intersectdist = 20 / 130 , roiradius = 60 / 130
428+ ):
429+ import glob
430+ from . import io , aim
431+ from numpy import savetxt
432+
433+ paths = glob .glob (files )
434+ for path in paths :
435+ try :
436+ locs , info = io .load_locs (path )
437+ except io .NoMetadataFileError :
438+ continue
439+ print ("Undrifting file {}" .format (path ))
440+ locs , new_info , drift = aim .aim (locs , info , segmentation , intersectdist , roiradius )
441+ base , ext = os .path .splitext (path )
442+ io .save_locs (base + "_aim.hdf5" , locs , new_info )
443+ savetxt (base + "_aimdrift.txt" , drift , header = "dx\t dy" , newline = "\r \n " )
444+
445+
426446def _density (files , radius ):
427447 import glob
428448
@@ -985,6 +1005,7 @@ def prompt_info():
9851005 print ("------------------------------------------" )
9861006
9871007 info .append (localize_info )
1008+ info .append (camera_info )
9881009
9891010 base , ext = splitext (path )
9901011
@@ -1210,12 +1231,12 @@ def main():
12101231 " specified by a unix style path pattern"
12111232 ),
12121233 )
1213- undrift_parser .add_argument (
1214- "-m" ,
1215- "--mode" ,
1216- default = "render" ,
1217- help = '"std", "render" or "framepair")' ,
1218- )
1234+ # undrift_parser.add_argument(
1235+ # "-m",
1236+ # "--mode",
1237+ # default="render",
1238+ # help='"std", "render" or "framepair")',
1239+ # )
12191240 undrift_parser .add_argument (
12201241 "-s" ,
12211242 "--segmentation" ,
@@ -1239,6 +1260,48 @@ def main():
12391260 help = "do not display estimated drift" ,
12401261 )
12411262
1263+ # undrift by AIM parser
1264+ undrift_aim_parser = subparsers .add_parser (
1265+ "aim" , help = "correct localization coordinates for drift with AIM"
1266+ )
1267+ undrift_aim_parser .add_argument (
1268+ "files" ,
1269+ help = (
1270+ "one or multiple hdf5 localization files"
1271+ " specified by a unix style path pattern"
1272+ ),
1273+ )
1274+ undrift_aim_parser .add_argument (
1275+ "-s" ,
1276+ "--segmentation" ,
1277+ type = float ,
1278+ default = 100 ,
1279+ help = (
1280+ "the number of frames to be combined"
1281+ " for one temporal segment (default=100)"
1282+ ),
1283+ )
1284+ undrift_aim_parser .add_argument (
1285+ "-i" ,
1286+ "--intersectdist" ,
1287+ type = float ,
1288+ default = 20 / 130 ,
1289+ help = (
1290+ "max. distance (cam. pixels) between localizations in"
1291+ " consecutive segments to be considered as intersecting"
1292+ ),
1293+ )
1294+ undrift_aim_parser .add_argument (
1295+ "-r" ,
1296+ "--roiradius" ,
1297+ type = float ,
1298+ default = 60 / 130 ,
1299+ help = (
1300+ "max. drift (cam. pixels) between two consecutive"
1301+ " segments"
1302+ ),
1303+ )
1304+
12421305 # local densitydd
12431306 density_parser = subparsers .add_parser (
12441307 "density" , help = "compute the local density of localizations"
@@ -1708,6 +1771,8 @@ def main():
17081771 )
17091772 elif args .command == "undrift" :
17101773 _undrift (args .files , args .segmentation , args .nodisplay , args .fromfile )
1774+ elif args .command == "aim" :
1775+ _undrift_aim (args .files , args .segmentation , args .intersectdist , args .roiradius )
17111776 elif args .command == "density" :
17121777 _density (args .files , args .radius )
17131778 elif args .command == "dbscan" :
0 commit comments