import sqlite3
from lmtanalysis.FileUtil import getFilesToProcess
from lmtanalysis.Animal import AnimalPool
from lmtanalysis.Measure import oneHour

if __name__ == '__main__':

    #ask the user for database to process
    files = getFilesToProcess()

    for file in files:

        # connect to database
        connection = sqlite3.connect(file)

        # create an animalPool, which basically contains your animals
        animalPool = AnimalPool()

        # load infos about the animals
        animalPool.loadAnimals(connection)

        # load all detection (positions) of all animals for the first hour
        animalPool.loadDetection(start=0, end=oneHour)

        # filter detection by animalSpeed (speed is in centimeters per second)
        animalPool.filterDetectionByInstantSpeed(30, 70)

        # plot and show trajectory
        animalPool.plotTrajectory(
            title="Trajectories filtered by speed (between 30 to 70 cm/s) ")
import sqlite3
from lmtanalysis.FileUtil import getFilesToProcess
from lmtanalysis.Animal import AnimalPool
from lmtanalysis.Measure import oneHour

if __name__ == '__main__':

    #ask the user for database to process
    files = getFilesToProcess()

    for file in files:

        # connect to database
        connection = sqlite3.connect(file)

        # create an animalPool, which basically contains your animals
        animalPool = AnimalPool()

        # load infos about the animals
        animalPool.loadAnimals(connection)

        # load all detection (positions) of all animals for the first hour
        animalPool.loadDetection(start=0, end=oneHour)

        # filter detection by animalSpeed (speed is in centimeters per second)
        animalPool.filterDetectionByInstantSpeed(0, 2)

        # plot and show trajectory
        animalPool.plotTrajectory(
            title="Trajectories filtered by speed (max 2) ")
import sqlite3
from lmtanalysis.FileUtil import getFilesToProcess
from lmtanalysis.Animal import AnimalPool
from lmtanalysis.Measure import oneHour, oneMinute

if __name__ == '__main__':

    #ask the user for database to process
    files = getFilesToProcess()

    for file in files:

        # connect to database
        connection = sqlite3.connect(file)

        # create an animalPool, which basically contains your animals
        animalPool = AnimalPool()

        # load infos about the animals
        animalPool.loadAnimals(connection)

        # load all detection (positions) of all animals for the first hour
        animalPool.loadDetection(start=0, end=10 * oneMinute)

        # filter detection by area (in cm from the top left of the cage)
        animalPool.filterDetectionByArea(0, 30, 25, 50)

        # plot and show trajectory
        animalPool.plotTrajectory(title="Trajectories filtered by area")
@author: Fab
'''

import sqlite3
from lmtanalysis.FileUtil import getFilesToProcess
from lmtanalysis.Animal import AnimalPool
from lmtanalysis.Measure import oneHour

if __name__ == '__main__':

    #ask the user for database to process
    files = getFilesToProcess()

    for file in files:

        # connect to database
        connection = sqlite3.connect(file)

        # create an animalPool, which basically contains your animals
        animalPool = AnimalPool()

        # load infos about the animals
        animalPool.loadAnimals(connection)

        # load all detection (positions) of all animals for the first hour
        animalPool.loadDetection(start=0, end=oneHour, lightLoad=True)

        # plot and show trajectory
        animalPool.plotTrajectory()
    files = getFilesToProcess()

    for file in files:

        # connect to database
        connection = sqlite3.connect(file)

        # create an animalPool, which basically contains your animals
        animalPool = AnimalPool()

        # load infos about the animals
        animalPool.loadAnimals(connection)

        # load all detection (positions) of all animals for the first hour
        animalPool.loadDetection(start=0, end=10 * oneMinute)

        # filter detection by area (in cm from the top left of the cage)
        animalPool.filterDetectionByArea(0, 30, 25, 50)

        # loop over all animals in this database
        for animal in animalPool.getAnimalList():

            # print RFID of animal
            print("Animal : ", animal.RFID)
            # distance traveled by animal (in cm):
            print("Distance traveled in area: (in centimeter): ",
                  animal.getDistance())

        animalPool.plotTrajectory(title="Trajectories filtered by area",
                                  scatter=True)