Skip to main content

A Python package for the analysis of the Mirror Tracing Task in polar coordinates

Project description

UrsaMirror

A Python package and GUI for analyzing the Mirror Tracing Task in polar coordinates.

PyPI - Version DOI PyPI - Python Version Contributor Covenant

Table of Contents

Highlights

  • Analyze the residuals and density of the drawing for every angle.
  • Save this values in a .csv file or work with them as a pandas DataFrame.
  • Transform the digitized paper drawing into and easy-to-work format.
  • Transform the results from this online version of the drawing task into and easy-to-work format.
  • Reconstruct the drawn path when it crosses the borders of the star.

Usage

UrsaMirror performs all of its analysis using a standardized image format where the red, green and blue channels contain, respectively, the drawn path, the inner part of the star, and the borders of the star. You can simply transform any digitized image into this format using either paper2std() or online2std() functions. With the transformed image, the basic analysis in polar coordinates can be done in few lines of code.

There are several provided examples that you can use to test the package. They are located in the raw_data folder, and are divided into app, paper and online source. The app drawings come from an application developed in our group, whichs uses the standardize format as output. The paper folder contains digitized drawings. The online folder contains images from this online version of the task.

Paper to standard version

Using one of the provided digitized paper examples, we can transform it into the standardized version:

import ursamirror as um

path_to_image = "/raw_data/paper/blue.png"

transformed_image = um.paper2std(path_to_image)

You can now access and visualize each of the channels:

import matplotlib.pylab as plt

fig, ax = plt.subplots(1,4, sharex=True,sharey=True)

ax[0].imshow(transformed_image[:,:,0], cmap="Reds")
ax[0].set_title("Path", fontsize=15)
ax[0].axis('off')

ax[1].imshow(transformed_image[:,:,1], cmap="Greens")
ax[1].set_title("Inner star", fontsize=15)
ax[1].axis('off')

ax[2].imshow(transformed_image[:,:,2], cmap="Blues")
ax[2].set_title("Borders", fontsize=15)
ax[2].axis('off')

ax[3].imshow(transformed_image)
ax[3].set_title("Transformed image", fontsize=15)
ax[3].axis('off')

plt.show()

Or you can just save it in the new format to be analyzed.

import ursamirror as um

path_to_image = "/raw_data/paper/blue.png"
new_path = "/processed_data/transformed_blue.png"

transformed_image = um.paper2std(path_to_image, new_path, save=True)

If you want to process a group of images, it can be done in a for loop. Check this simple example

import ursamirror as um
import os 

path_to_folder = "/raw_data/paper/"
path_to_new_folder = "/processed_data/"

for file in os.listdir(path_to_folder):
    if ".png" in file:
        image_name = file
        #In Windows, change "/" by "\"
        path_to_image = path_to_folder + "/" + image_name

        new_name = "transformed_" + image_name
        new_path = "/processed_data/" + "/" + new_name

        transformed_image = um.paper2std(path_to_image, new_path, save=True)

Online to standard version

The procedure is the same as the above. The only change here is the function to be used:

import ursamirror as um

path_to_image = "/raw_data/online/00_online.png"

transformed_image = um.online2std(path_to_image)

#or saving the image
new_path = "/processed_data/transformed_00_online.png"
transformed_image = um.online2std(path_to_image, new_path, save=True)

Star analysis

Once you have a star in the standardized format, the basic analysis and export can be done as:

import ursamirror as um

path_to_image = "/processed_data/transformed_blue.png"

star = um.STAR(path_to_image)
export_data = star.export()
export_data.to_csv("/processed_data/transformed_blue.csv", index=False)

"transformed_blue.csv" will now contain 5 columns: The angles (in radians), the angles (in degrees), the density, the residuals, and the squared residuals.

You can also pre-visualize the results

star = um.STAR(path_to_image)
star.plot()

There are some other methods and attributes connected to the STAR object. The basic usage of the package are summarized above, but you can also get:

  • Access to the path, inner star, and border, as from the standardized format.
  • The skeleton of the path
  • The inner/outer borders and their fitted coefficients.
  • The center coordinates of the star in the image
  • The estimated path thickness of the star.
  • The drawn path and its skeleton in polar coordinates
  • The residuals
  • The density

Installation

pip install ursamirror
pip install ursamirror@git+https://github.com/PabloFGarrido/ursamirror

If you are not comfortable working with Python or programming, try the GUI that you can find in the exec folder.

Windows: Download ursamiror_windows and run it.

MacOS and Linux: Download ursamiror_linux and run it from the terminal. From the same directory where the file is located,

./ursamiror_linux

License

ursamirror is distributed under the terms of the MIT license.

How to cite

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ursamirror-0.2.4.tar.gz (2.1 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ursamirror-0.2.4-py3-none-any.whl (19.9 kB view details)

Uploaded Python 3

File details

Details for the file ursamirror-0.2.4.tar.gz.

File metadata

  • Download URL: ursamirror-0.2.4.tar.gz
  • Upload date:
  • Size: 2.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.27.0

File hashes

Hashes for ursamirror-0.2.4.tar.gz
Algorithm Hash digest
SHA256 d11e56e742253e5c87a20da095824657c8fa6ac277d6ca2f05322dbc210cdbae
MD5 d1bfafa9d4a8d5e6653e0594907ef1ec
BLAKE2b-256 2b70fc93d2503f702190facd087f2cba7157d95f7dda70fe6d2488686e725667

See more details on using hashes here.

File details

Details for the file ursamirror-0.2.4-py3-none-any.whl.

File metadata

  • Download URL: ursamirror-0.2.4-py3-none-any.whl
  • Upload date:
  • Size: 19.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.27.0

File hashes

Hashes for ursamirror-0.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 dd0729570f08176b8b6345b43ccfff4004d1332d5b24b9d1350c452f0cd63116
MD5 4877c7ac24eb8df1f8e33685bcbffcd2
BLAKE2b-256 3903d1a0040e2c322b470d0ee74a3046c08271eb0d4c995d3da62f772fc01ea6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page