Metadata-Version: 2.4
Name: discopat
Version: 0.4.2
Summary: DISCOver PATterns (DISCOPAT)
Author-email: Mansour Benbakoura <mansour.benbakoura@inria.fr>
License: BSD 3-Clause License
        
        Copyright (c) 2025, the discopat authors.
        All rights reserved.
        
        Redistribution and use in source and binary forms, with or without
        modification, are permitted provided that the following conditions are met:
        
        * Redistributions of source code must retain the above copyright notice, this
          list of conditions and the following disclaimer.
        
        * Redistributions in binary form must reproduce the above copyright notice,
          this list of conditions and the following disclaimer in the documentation
          and/or other materials provided with the distribution.
        
        * Neither the name of the copyright holder nor the names of its
          contributors may be used to endorse or promote products derived from
          this software without specific prior written permission.
        
        THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
        AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
        IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
        DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
        FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
        DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
        SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
        CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
        OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
        OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Project-URL: Repository, https://github.com/mansour-b/discopat
Project-URL: Documentation, https://discopat.readthedocs.io
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Requires-Python: >=3.9
Description-Content-Type: text/x-rst
License-File: LICENSE
Requires-Dist: filterpy
Requires-Dist: h5py
Requires-Dist: imageio
Requires-Dist: ipykernel
Requires-Dist: matplotlib
Requires-Dist: moviepy<2
Requires-Dist: numpy
Requires-Dist: osfclient
Requires-Dist: pycocotools
Requires-Dist: PyYAML
Requires-Dist: scikit-image
Requires-Dist: torch
Requires-Dist: torchaudio
Requires-Dist: torchvision
Requires-Dist: tqdm
Provides-Extra: dev
Requires-Dist: ruff; extra == "dev"
Provides-Extra: doc
Requires-Dist: sphinx; extra == "doc"
Requires-Dist: sphinx-gallery; extra == "doc"
Requires-Dist: sphinx_rtd_theme; extra == "doc"
Provides-Extra: test
Requires-Dist: pytest; extra == "test"
Requires-Dist: pytest-cov; extra == "test"
Dynamic: license-file

.. image:: https://raw.githubusercontent.com/mansour-b/discopat/main/assets/discopat_hollywood.png
   :align: center

DISCOver PATterns (DISCOPAT)
----------------------------

|Build Status| |Code Coverage| |PyPI Version| |Python Versions| |License| |Downloads| |Docs|

Welcome to ``discopat``, the pattern discovery library!

This library provides tools to discover, detect, and track meaningful patterns
in physical signals. These signals can be of various forms:

1. Time series,
2. Images,
3. Movies,
4. Any other type of n-dimensional data.

Installation
------------

You can install ``discopat`` by doing the following::

    pip install discopat

You can then try running `this notebook
<https://github.com/mansour-b/discopat/blob/main/examples/plot_model_inference.py>`_
on your computer to verify that the installation was succesful.

Quickstart
----------

Here is an example to briefly present the API:

.. code:: python

    import numpy as np

    from discopat.core import Box, Frame, Model, Movie, Tracker
    from discopat.display import plot_frame

    # Define the dimensions of the problem
    frame_width = 5
    frame_height = 5
    movie_length = 3
    gif_frames_per_second = 2

    # Define a concrete model class, just for the example
    class DumbModel(Model):
        def predict(self, frame: Frame) -> Frame:
            frame_id = int(frame.name)
            frame.annotations.append(
                Box(label="noise_in_a_square", x=frame_id, y=frame_id, width=1, height=1)
            )
            return frame

    model = DumbModel()

    # Our data for this short tutorial
    frames = [
        Frame(
            name=str(10 * i),
            width=frame_width,
            height=frame_height,
            annotations=[],
            image_array=np.random.random(frame_height, frame_width),
        )
        for i in range(movie_length)
    ]

    movie = Movie(name="some_noise", frames=frames, tracks=[])

    # Run the detection model on individual frames
    analysed_frames = [model(frame) for frame in movie.frames]
    analysed_movie = Movie(
        name="some_noise_with_boxes", frames=analysed_frames, tracks=[]
    )

    # TBD: run tracker on detections
    analysed_movie = tracker.make_tracks(analysed_movie)
    analysed_movie.name = "some_noise_with_boxes_and_tracks"

    # Plot individual frames with detections
    for frame in analysed_movie:
        plot_frame(frame)

    # TBD: make a GIF to show the tracks
    export_to_gif(analysed_movie, fps=gif_frames_per_seconds)

.. |Build Status| image:: https://github.com/mansour-b/discopat/actions/workflows/pytest.yaml/badge.svg
   :target: https://github.com/mansour-b/discopat/actions/workflows/pytest.yaml

.. |Code Coverage| image:: https://codecov.io/github/mansour-b/discopat/graph/badge.svg
   :target: https://codecov.io/github/mansour-b/discopat

.. |PyPI Version| image:: https://img.shields.io/pypi/v/discopat.svg
   :target: https://pypi.org/project/discopat/

.. |Python Versions| image:: https://img.shields.io/pypi/pyversions/discopat.svg
   :target: https://pypi.org/project/discopat/

.. |License| image:: https://img.shields.io/github/license/mansour-b/discopat.svg
   :target: https://github.com/mansour-b/discopat/blob/main/LICENSE

.. |Downloads| image:: https://static.pepy.tech/badge/discopat
   :target: https://pepy.tech/project/myproject

.. |Docs| image:: https://readthedocs.org/projects/discopat/badge/?version=latest
   :target: https://discopat.readthedocs.io/en/latest/

