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.3.tar.gz (1.6 MB view details)

Uploaded Source

Built Distribution

ursamirror-0.2.3-py3-none-any.whl (17.7 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for ursamirror-0.2.3.tar.gz
Algorithm Hash digest
SHA256 3bca5b605148e1be505c550b144d4f9d1b7cb07418b0c08c4636d4f025330a1b
MD5 44d2aef2052bcffaa21e24c4538c0744
BLAKE2b-256 dd8a20cbb59486ed872cdccc5923a6df904e955edd9c57dd51395f861df40c62

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for ursamirror-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 76b87127c5ea04255922266b4c86be1854269ca839c310b58d710ef6572ae8ac
MD5 fd21b762a47ef91f09e7d3c17b97c3df
BLAKE2b-256 be8e22b9bda3f800a5082bb0633ef758f342c854acc32284c18967fcfeaeb7b0

See more details on using hashes here.

Supported by

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