Package: shareloc-utils
ShareLoc UtilitiesUtility tools for ShareLoc.XYZ in PythonFeaturesBatch Downloading datasets fromhttps://shareloc.xyzwebsiteParser for *.smlm filesInstallationpip install -U shareloc-utilsIf you want to use the shareloc potree viewer:pip install -U shareloc-utils[potree]Usage for batch downloadingThe easiest way to download the dataset is to go tohttps://shareloc.xyzand click the download icon on the dataset.You will then get a generated command which you can use for downloading the dataset.If you want to know how the generated commands works, here we will give a few examples.Basically, you can pass datasets url directly to the command line like this:python -m shareloc_utils.batch_download --datasets=https://sandbox.zenodo.org/record/891810 --output_dir=./outputIf you want to download multiple datasets, use comma to separate multiple dataset URL or just Zenodo IDs.python -m shareloc_utils.batch_download --datasets=891810,887832 --sandbox --output_dir=./outputNote that when you use Zenodo ID, you will need an additional parameter--sandboxif you are using the sandbox server.If you want to convert the downloaded dataset to text file format (e.g. CSV), you can add--conversionafter the command. If you want to generate a potree octree for visualization, set--extension=".potree"(a potree folder) or--extension=".potree.zip"(a zipped potree file).To print all other options, type:python -m shareloc_utils.batch_download --helpDownloading multiple datasetsThe ShareLoc.XYZ website support bookmark feature (similar to a shopping cart) which you can mark multiple datasets and download them all.To use it, you move your mouse on top of the dataset card you are interested in, then click the bookmark icon to mark it. Repeat the process and mark all the datasets you want to download. Then click the bookmark icon in the navigation bar and click "Download All".Use the SMLM file parserIn Python, you use theread_smlm_filefunction to parse the *.smlm file downloaded from ShareLoc(https://shareloc.xyz).In the following example, we first parse the tables in the smlm file, then generate a histogram image:fromPILimportImagefromshareloc_utils.smlm_fileimportread_smlm_file,plot_histogram# parse the .smlm filemanifest=read_smlm_file("./localization_table.smlm")# one file can contain multiple localization tablestables=manifest["files"]# generate a histogram image for the first tablehistogram=plot_histogram(tables[0]["data"],value_range=(0,255))# save the histogram image as 16-bit png fileim=Image.fromarray(histogram.astype("uint16"))im.save("output.png")DevelopmentInstall and set up development environment.pipinstall-rrequirements_dev.txtThis will install all requirements.
It will also install this package in development mode, so that code changes are applied immediately without reinstall necessary.Here's a list of development tools we use.blackflake8mypypydocstylepylintpytesttoxIt's recommended to use the corresponding code formatter and linters also in your code editor to get instant feedback. A popular editor that can do this isvscode.Run all tests, check formatting and linting.toxRun a single tox environment.tox-elintReinstall all tox environments.tox-rRun pytest and all tests.pytestRun pytest and calculate coverage for the package.pytest--cov-reportterm-missing--cov=shareloc_utilsContinuous integration is by default supported viaGitHub actions. GitHub actions is free for public repositories and comes with 2000 free Ubuntu build minutes per month for private repositories.