diff --git a/EMT/EMT_notebooks/Rebuild_All_Events_LMT.ipynb b/EMT/EMT_notebooks/Rebuild_All_Events_LMT.ipynb index f04ab8f938c5405af18a48c29f9b5bc641c8c36e..d596977b07daece71d5d4fa430a37f717ea18d60 100644 --- a/EMT/EMT_notebooks/Rebuild_All_Events_LMT.ipynb +++ b/EMT/EMT_notebooks/Rebuild_All_Events_LMT.ipynb @@ -35,13 +35,12 @@ " BuildEventFloorSniffing, BuildEventSocialApproach, BuildEventSocialEscape, BuildEventApproachContact, \\\n", " BuildEventOralOralContact, BuildEventApproachRear, BuildEventGroup2, BuildEventGroup3, BuildEventGroup4, \\\n", " BuildEventOralGenitalContact, BuildEventStop, BuildEventMove, BuildEventGroup3MakeBreak, BuildEventGroup4MakeBreak, \\\n", - " BuildEventSideBySide, BuildEventSideBySideOpposite, BuildDataBaseIndex, BuildEventWallJump, BuildEventSAP, \\\n", + " BuildEventSideBySide, BuildEventSideBySideOpposite, BuildEventWallJump, BuildEventSAP, \\\n", " BuildEventOralSideSequence, CheckWrongAnimal, BuildEventDetection, BuildEventCenterPeripheryLocation, BuildEventNest4, \\\n", " BuildEventNest3, BuildEventGetAway, BuildEventOtherContact, BuildEventPassiveAnogenitalSniff, BuildEventRearCenterPeriphery\n", "from lmtanalysis.TaskLogger import TaskLogger\n", "from lmtanalysis.FileUtil import getFilesToProcess\n", "from lmtanalysis.EventTimeLineCache import flushEventTimeLineCache, disableEventTimeLineCache\n", - "from lmtanalysis.EventTimeLineCache import EventTimeLineCached\n", "from lmtanalysis.AnimalType import AnimalType\n" ] }, @@ -192,17 +191,6 @@ " except:\n", " print( \"METADATA field already exists\" , file )\n", "\n", - " #build index\n", - "\n", - " BuildDataBaseIndex.buildDataBaseIndex( connection, force=False )\n", - "\n", - " '''\n", - " # build sensor data\n", - " animalPool = AnimalPool( )\n", - " animalPool.loadAnimals( connection )\n", - " animalPool.buildSensorData(file)\n", - " '''\n", - "\n", " currentT = minT\n", "\n", " try:\n", diff --git a/EMT/EMT_notebooks/Rebuild_Huddling_events.ipynb b/EMT/EMT_notebooks/Rebuild_Huddling_events.ipynb index 9bc5997aaed664fa67a1f1943e8273851cb56989..7f160dcebed79f9a89d4ec699ef45fd0c0f4fa8d 100644 --- a/EMT/EMT_notebooks/Rebuild_Huddling_events.ipynb +++ b/EMT/EMT_notebooks/Rebuild_Huddling_events.ipynb @@ -47,9 +47,7 @@ "minT = 0\n", "maxT = 1*oneDay\n", "''' time window to compute the events (in frame). '''\n", - "windowT = 1*oneDay\n", - "''' speed up process '''\n", - "USE_CACHE_LOAD_DETECTION_CACHE = True" + "windowT = 1*oneDay\n" ] }, { @@ -79,7 +77,7 @@ "from lmtanalysis.Animal import *\n", "from lmtanalysis.Event import *\n", "from lmtanalysis.Measure import *\n", - "from lmtanalysis import BuildEventHuddling, BuildEventHuddling_oldv, BuildEventHuddling_parallel, BuildDataBaseIndex\n", + "from lmtanalysis import BuildEventHuddling, BuildEventHuddling_oldv, BuildEventHuddling_parallel\n", "from lmtanalysis.FileUtil import getFilesToProcess\n", "from lmtanalysis.EventTimeLineCache import flushEventTimeLineCache, disableEventTimeLineCache\n", "from lmtanalysis.AnimalType import AnimalType\n", @@ -99,39 +97,31 @@ "\n", "\n", "def processTimeWindow(file, connection, currentMinT , currentMaxT, mode=\"new\"):\n", - "\n", " animalPool = None\n", " flushEventTimeLineCache()\n", "\n", - " if (USE_CACHE_LOAD_DETECTION_CACHE):\n", - " print(\"Caching load of animal detection...\")\n", - " animalPool = AnimalPool()\n", - " animalPool.loadAnimals(connection)\n", - " animalPool.loadDetection(start = currentMinT, end = currentMaxT)\n", - " print(\"Caching load of animal detection done.\")\n", - "\n", - " chrono = Chronometer(str(BuildEventHuddling))\n", - " if \"old\" in mode.lower():\n", - " BuildEventHuddling_oldv.reBuildEvent(connection, file,\n", - " tmin=currentMinT,\n", - " tmax=currentMaxT,\n", - " pool = animalPool,\n", - " animalType = AnimalType.MOUSE)\n", - " elif \"new\" in mode.lower():\n", - " BuildEventHuddling.reBuildEvent(connection, file,\n", - " tmin=currentMinT,\n", - " tmax=currentMaxT,\n", - " pool = animalPool,\n", - " animalType = AnimalType.MOUSE)\n", - " elif \"parallel\" in mode.lower():\n", - " BuildEventHuddling_parallel.reBuildEvent(connection, file,\n", - " tmin=currentMinT,\n", - " tmax=currentMaxT,\n", - " pool = animalPool,\n", - " animalType = AnimalType.MOUSE)\n", - " else:\n", - " raise NotImplementedError(\"This mode does not exist. Use 'old', 'new' or 'parallel'\")\n", - " chrono.printTimeInS()\n", + " chrono = Chronometer(str(BuildEventHuddling))\n", + " if \"old\" in mode.lower():\n", + " BuildEventHuddling_oldv.reBuildEvent(connection, file,\n", + " tmin=currentMinT,\n", + " tmax=currentMaxT,\n", + " pool = animalPool,\n", + " animalType = AnimalType.MOUSE)\n", + " elif \"new\" in mode.lower():\n", + " BuildEventHuddling.reBuildEvent(connection, file,\n", + " tmin=currentMinT,\n", + " tmax=currentMaxT,\n", + " pool = animalPool,\n", + " animalType = AnimalType.MOUSE)\n", + " elif \"parallel\" in mode.lower():\n", + " BuildEventHuddling_parallel.reBuildEvent(connection, file,\n", + " tmin=currentMinT,\n", + " tmax=currentMaxT,\n", + " pool = animalPool,\n", + " animalType = AnimalType.MOUSE)\n", + " else:\n", + " raise NotImplementedError(\"This mode does not exist. Use 'old', 'new' or 'parallel'\")\n", + " chrono.printTimeInS()\n", "\n", "def process(file, mode=\"new\"):\n", "\n", @@ -158,9 +148,6 @@ " except:\n", " print(\"METADATA field already exists\" , file)\n", "\n", - " # Build Index\n", - " BuildDataBaseIndex.buildDataBaseIndex(connection, force=False)\n", - "\n", " currentT = minT\n", "\n", " try:\n", @@ -193,6 +180,9 @@ "\n", " raise FileProcessException()\n", "\n", + " connection.close()\n", + "\n", + "\n", "print(\"Code launched.\")\n", "\n", "mem = virtual_memory()\n", diff --git a/EMT/EMT_notebooks/Rebuild_InterestZone_events.ipynb b/EMT/EMT_notebooks/Rebuild_InterestZone_events.ipynb index d96443f277661c45423f283c64677965e1693c49..019f8962b765f261755bab000a587304c2f4090d 100644 --- a/EMT/EMT_notebooks/Rebuild_InterestZone_events.ipynb +++ b/EMT/EMT_notebooks/Rebuild_InterestZone_events.ipynb @@ -39,9 +39,7 @@ "minT = 0\n", "maxT = 3*oneDay\n", "''' time window to compute the events (in frame). '''\n", - "windowT = 1*oneDay\n", - "''' speed up process '''\n", - "USE_CACHE_LOAD_DETECTION_CACHE = True" + "windowT = 1*oneDay\n" ] }, { @@ -74,11 +72,10 @@ "from lmtanalysis.Animal import *\n", "from lmtanalysis.TaskLogger import TaskLogger\n", "from lmtanalysis.Event import *\n", - "from lmtanalysis.Measure import *\n", - "from lmtanalysis.Util import getAllEvents, getNumberOfFrames\n", - "from lmtanalysis import BuildEventInterestZoneLocation, BuildDataBaseIndex\n", + "from lmtanalysis.Util import getNumberOfFrames\n", + "from lmtanalysis import BuildEventInterestZoneLocation\n", "from lmtanalysis.FileUtil import getFilesToProcess\n", - "from lmtanalysis.EventTimeLineCache import EventTimeLineCached, flushEventTimeLineCache, disableEventTimeLineCache\n", + "from lmtanalysis.EventTimeLineCache import flushEventTimeLineCache, disableEventTimeLineCache\n", "from lmtanalysis.AnimalType import AnimalType\n", "from lmtanalysis.Parameters import getAnimalTypeParameters\n", "\n", @@ -128,18 +125,11 @@ " animalPool = None\n", " flushEventTimeLineCache()\n", "\n", - " if ( USE_CACHE_LOAD_DETECTION_CACHE ):\n", - " print(\"Caching load of animal detection...\")\n", - " animalPool = AnimalPool()\n", - " animalPool.loadAnimals(connection)\n", - " animalPool.loadDetection(start = currentMinT, end = currentMaxT)\n", - " print(\"Caching load of animal detection done.\")\n", - "\n", - " chrono = Chronometer(str(BuildEventInterestZoneLocation))\n", - " BuildEventInterestZoneLocation.reBuildEvent( connection, file, tmin=currentMinT, tmax=currentMaxT,\n", - " pool = animalPool, animalType = AnimalType.MOUSE,\n", - " zone_name=zone_name, zone=zone_coords )\n", - " chrono.printTimeInS()\n", + " chrono = Chronometer(str(BuildEventInterestZoneLocation))\n", + " BuildEventInterestZoneLocation.reBuildEvent(connection, file, tmin=currentMinT, tmax=currentMaxT,\n", + " pool = animalPool, animalType = AnimalType.MOUSE,\n", + " zone_name=zone_name, zone=zone_coords )\n", + " chrono.printTimeInS()\n", "\n", "def process(file, zone_name, zone_coords):\n", " print(file)\n", @@ -168,9 +158,6 @@ " except:\n", " print( \"METADATA field already exists\" , file )\n", "\n", - " # Build Index\n", - " BuildDataBaseIndex.buildDataBaseIndex( connection, force=False )\n", - "\n", " currentT = minT\n", "\n", " try:\n", @@ -200,6 +187,8 @@ "\n", " raise FileProcessException()\n", "\n", + " connection.close()\n", + "\n", "def extractFrames(video_file, count):\n", " cap = cv2.VideoCapture(video_file.absolute().__str__())\n", " frame = None\n", @@ -299,7 +288,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "LMT", "language": "python", "name": "python3" }, diff --git a/EMT/EMT_notebooks/Rebuild_SAP_events.ipynb b/EMT/EMT_notebooks/Rebuild_SAP_events.ipynb index edf086a03d64b439e297d35a935c49b7d8ff2681..b63c7b66c7d23fecf917dfc31d622bde758cf238 100644 --- a/EMT/EMT_notebooks/Rebuild_SAP_events.ipynb +++ b/EMT/EMT_notebooks/Rebuild_SAP_events.ipynb @@ -39,9 +39,7 @@ "minT = 0\n", "maxT = 1*oneDay\n", "''' time window to compute the events (in frame). '''\n", - "windowT = 1*oneDay\n", - "''' speed up process '''\n", - "USE_CACHE_LOAD_DETECTION_CACHE = True" + "windowT = 1*oneDay\n" ] }, { @@ -70,7 +68,7 @@ "from lmtanalysis.TaskLogger import TaskLogger\n", "from lmtanalysis.Animal import *\n", "from lmtanalysis.Event import *\n", - "from lmtanalysis import BuildEventSAP, BuildEventSAP_oldv, BuildEventSAP_parallel, BuildDataBaseIndex\n", + "from lmtanalysis import BuildEventSAP, BuildEventSAP_oldv, BuildEventSAP_parallel\n", "from lmtanalysis.FileUtil import getFilesToProcess\n", "from lmtanalysis.EventTimeLineCache import flushEventTimeLineCache, disableEventTimeLineCache\n", "from lmtanalysis.AnimalType import AnimalType\n", @@ -94,35 +92,28 @@ " animalPool = None\n", " flushEventTimeLineCache()\n", "\n", - " if (USE_CACHE_LOAD_DETECTION_CACHE):\n", - " print(\"Caching load of animal detection...\")\n", - " animalPool = AnimalPool()\n", - " animalPool.loadAnimals(connection)\n", - " animalPool.loadDetection(start = currentMinT, end = currentMaxT)\n", - " print(\"Caching load of animal detection done.\")\n", - "\n", - " chrono = Chronometer(str(BuildEventSAP))\n", - " if \"old\" in mode.lower():\n", - " BuildEventSAP_oldv.reBuildEvent(connection, file,\n", - " tmin=currentMinT,\n", - " tmax=currentMaxT,\n", - " pool = animalPool,\n", - " animalType = AnimalType.MOUSE)\n", - " elif \"new\" in mode.lower():\n", - " BuildEventSAP.reBuildEvent(connection, file,\n", - " tmin=currentMinT,\n", - " tmax=currentMaxT,\n", - " pool = animalPool,\n", - " animalType = AnimalType.MOUSE)\n", - " elif \"parallel\" in mode.lower():\n", - " BuildEventSAP_parallel.reBuildEvent(connection, file,\n", - " tmin=currentMinT,\n", - " tmax=currentMaxT,\n", - " pool = animalPool,\n", - " animalType = AnimalType.MOUSE)\n", - " else:\n", - " raise NotImplementedError(\"This mode does not exist. Use 'old', 'new' or 'parallel'\")\n", - " chrono.printTimeInS()\n", + " chrono = Chronometer(str(BuildEventSAP))\n", + " if \"old\" in mode.lower():\n", + " BuildEventSAP_oldv.reBuildEvent(connection, file,\n", + " tmin=currentMinT,\n", + " tmax=currentMaxT,\n", + " pool = animalPool,\n", + " animalType = AnimalType.MOUSE)\n", + " elif \"new\" in mode.lower():\n", + " BuildEventSAP.reBuildEvent(connection, file,\n", + " tmin=currentMinT,\n", + " tmax=currentMaxT,\n", + " pool = animalPool,\n", + " animalType = AnimalType.MOUSE)\n", + " elif \"parallel\" in mode.lower():\n", + " BuildEventSAP_parallel.reBuildEvent(connection, file,\n", + " tmin=currentMinT,\n", + " tmax=currentMaxT,\n", + " pool = animalPool,\n", + " animalType = AnimalType.MOUSE)\n", + " else:\n", + " raise NotImplementedError(\"This mode does not exist. Use 'old', 'new' or 'parallel'\")\n", + " chrono.printTimeInS()\n", "\n", "def process(file, mode=\"new\"):\n", "\n", @@ -149,9 +140,6 @@ " except:\n", " print(\"METADATA field already exists\" , file)\n", "\n", - " # Build Index\n", - " BuildDataBaseIndex.buildDataBaseIndex(connection, force=False)\n", - "\n", " currentT = minT\n", "\n", " try:\n", @@ -183,6 +171,9 @@ "\n", " raise FileProcessException()\n", "\n", + " connection.close()\n", + "\n", + "\n", "print(\"Code launched.\")\n", "\n", "mem = virtual_memory()\n", diff --git a/EMT/EMT_notebooks/Rebuild_WallJump_events.ipynb b/EMT/EMT_notebooks/Rebuild_WallJump_events.ipynb index f7482ea61838631fa099dd01e25a1b7d0ec9f288..7bd3db4d862ab7f27b2b81ba7811b98409a4afcb 100644 --- a/EMT/EMT_notebooks/Rebuild_WallJump_events.ipynb +++ b/EMT/EMT_notebooks/Rebuild_WallJump_events.ipynb @@ -39,9 +39,7 @@ "minT = 0\n", "maxT = 1*oneDay\n", "''' time window to compute the events (in frame). '''\n", - "windowT = 1*oneDay\n", - "''' speed up process '''\n", - "USE_CACHE_LOAD_DETECTION_CACHE = True" + "windowT = 1*oneDay\n" ] }, { @@ -70,8 +68,7 @@ "from lmtanalysis.TaskLogger import TaskLogger\n", "from lmtanalysis.Animal import *\n", "from lmtanalysis.Event import *\n", - "from lmtanalysis.Measure import *\n", - "from lmtanalysis import BuildEventWallJump, BuildEventWallJump_oldv, BuildEventWallJump_parallel, BuildDataBaseIndex\n", + "from lmtanalysis import BuildEventWallJump, BuildEventWallJump_oldv, BuildEventWallJump_parallel\n", "from lmtanalysis.FileUtil import getFilesToProcess\n", "from lmtanalysis.EventTimeLineCache import flushEventTimeLineCache, disableEventTimeLineCache\n", "from lmtanalysis.AnimalType import AnimalType\n", @@ -95,35 +92,28 @@ " animalPool = None\n", " flushEventTimeLineCache()\n", "\n", - " if (USE_CACHE_LOAD_DETECTION_CACHE):\n", - " print(\"Caching load of animal detection...\")\n", - " animalPool = AnimalPool()\n", - " animalPool.loadAnimals(connection)\n", - " animalPool.loadDetection(start = currentMinT, end = currentMaxT)\n", - " print(\"Caching load of animal detection done.\")\n", - "\n", - " chrono = Chronometer(str(BuildEventWallJump))\n", - " if \"old\" in mode.lower():\n", - " BuildEventWallJump_oldv.reBuildEvent(connection, file,\n", - " tmin=currentMinT,\n", - " tmax=currentMaxT,\n", - " pool = animalPool,\n", - " animalType = AnimalType.MOUSE)\n", - " elif \"new\" in mode.lower():\n", - " BuildEventWallJump.reBuildEvent(connection, file,\n", - " tmin=currentMinT,\n", - " tmax=currentMaxT,\n", - " pool = animalPool,\n", - " animalType = AnimalType.MOUSE)\n", - " elif \"parallel\" in mode.lower():\n", - " BuildEventWallJump_parallel.reBuildEvent(connection, file,\n", - " tmin=currentMinT,\n", - " tmax=currentMaxT,\n", - " pool = animalPool,\n", - " animalType = AnimalType.MOUSE)\n", - " else:\n", - " raise NotImplementedError(\"This mode does not exist. Use 'old', 'new' or 'parallel'\")\n", - " chrono.printTimeInS()\n", + " chrono = Chronometer(str(BuildEventWallJump))\n", + " if \"old\" in mode.lower():\n", + " BuildEventWallJump_oldv.reBuildEvent(connection, file,\n", + " tmin=currentMinT,\n", + " tmax=currentMaxT,\n", + " pool = animalPool,\n", + " animalType = AnimalType.MOUSE)\n", + " elif \"new\" in mode.lower():\n", + " BuildEventWallJump.reBuildEvent(connection, file,\n", + " tmin=currentMinT,\n", + " tmax=currentMaxT,\n", + " pool = animalPool,\n", + " animalType = AnimalType.MOUSE)\n", + " elif \"parallel\" in mode.lower():\n", + " BuildEventWallJump_parallel.reBuildEvent(connection, file,\n", + " tmin=currentMinT,\n", + " tmax=currentMaxT,\n", + " pool = animalPool,\n", + " animalType = AnimalType.MOUSE)\n", + " else:\n", + " raise NotImplementedError(\"This mode does not exist. Use 'old', 'new' or 'parallel'\")\n", + " chrono.printTimeInS()\n", "\n", "def process(file, mode=\"new\"):\n", "\n", @@ -150,9 +140,6 @@ " except:\n", " print(\"METADATA field already exists\" , file)\n", "\n", - " # Build Index\n", - " BuildDataBaseIndex.buildDataBaseIndex(connection, force=False)\n", - "\n", " currentT = minT\n", "\n", " try:\n", @@ -184,6 +171,9 @@ "\n", " raise FileProcessException()\n", "\n", + " connection.close()\n", + "\n", + "\n", "print(\"Code launched.\")\n", "\n", "mem = virtual_memory()\n", diff --git a/EMT/EMT_notebooks/Rebuild_WaterZone_events.ipynb b/EMT/EMT_notebooks/Rebuild_WaterZone_events.ipynb index fa6c264929baff054262a5c4a9237ad2be45163b..1c94e5b3de9fcb822d6b160f928d6531468d8ca6 100644 --- a/EMT/EMT_notebooks/Rebuild_WaterZone_events.ipynb +++ b/EMT/EMT_notebooks/Rebuild_WaterZone_events.ipynb @@ -43,9 +43,7 @@ "minT = 0\n", "maxT = 3*oneDay\n", "''' time window to compute the events (in frame). '''\n", - "windowT = 1*oneDay\n", - "''' speed up process '''\n", - "USE_CACHE_LOAD_DETECTION_CACHE = True" + "windowT = 1*oneDay\n" ] }, { @@ -80,10 +78,10 @@ "from lmtanalysis.TaskLogger import TaskLogger\n", "from lmtanalysis.Event import *\n", "from lmtanalysis.Measure import *\n", - "from lmtanalysis.Util import getAllEvents, getNumberOfFrames\n", - "from lmtanalysis import BuildEventWaterPoint, BuildDataBaseIndex\n", + "from lmtanalysis.Util import getNumberOfFrames\n", + "from lmtanalysis import BuildEventWaterPoint\n", "from lmtanalysis.FileUtil import getFilesToProcess\n", - "from lmtanalysis.EventTimeLineCache import EventTimeLineCached, flushEventTimeLineCache, disableEventTimeLineCache\n", + "from lmtanalysis.EventTimeLineCache import flushEventTimeLineCache, disableEventTimeLineCache\n", "from lmtanalysis.AnimalType import AnimalType\n", "from lmtanalysis.Parameters import getAnimalTypeParameters\n", "\n", @@ -133,16 +131,9 @@ " animalPool = None\n", " flushEventTimeLineCache()\n", "\n", - " if ( USE_CACHE_LOAD_DETECTION_CACHE ):\n", - " print(\"Caching load of animal detection...\")\n", - " animalPool = AnimalPool()\n", - " animalPool.loadAnimals(connection)\n", - " animalPool.loadDetection(start = currentMinT, end = currentMaxT)\n", - " print(\"Caching load of animal detection done.\")\n", - "\n", - " chrono = Chronometer(str(BuildEventWaterPoint))\n", - " BuildEventWaterPoint.reBuildEvent( connection, file, tmin=currentMinT, tmax=currentMaxT, pool = animalPool, animalType = AnimalType.MOUSE, x_wp=wp[0], y_wp=wp[1] )\n", - " chrono.printTimeInS()\n", + " chrono = Chronometer(str(BuildEventWaterPoint))\n", + " BuildEventWaterPoint.reBuildEvent(connection, file, tmin=currentMinT, tmax=currentMaxT, pool = animalPool, animalType = AnimalType.MOUSE, x_wp=wp[0], y_wp=wp[1])\n", + " chrono.printTimeInS()\n", "\n", "def process( file, wp ):\n", " print(file)\n", @@ -168,9 +159,6 @@ " except:\n", " print( \"METADATA field already exists\" , file )\n", "\n", - " # Build Index\n", - " BuildDataBaseIndex.buildDataBaseIndex( connection, force=False )\n", - "\n", " currentT = minT\n", "\n", " try:\n", @@ -202,6 +190,8 @@ "\n", " raise FileProcessException()\n", "\n", + " connection.close()\n", + "\n", "def extractFrames(video_file, count):\n", " cap = cv2.VideoCapture(video_file.absolute().__str__())\n", " frame = None\n", diff --git a/EMT/EMT_scripts/Rebuild_All_Events_LMT_script.py b/EMT/EMT_scripts/Rebuild_All_Events_LMT_script.py index 089786cb13460b21be0c6d8c76a149baae80e3bb..d8ca77ec5b96880532af77767b3d0fa505744ff8 100644 --- a/EMT/EMT_scripts/Rebuild_All_Events_LMT_script.py +++ b/EMT/EMT_scripts/Rebuild_All_Events_LMT_script.py @@ -16,7 +16,7 @@ from lmtanalysis import BuildEventTrain3, BuildEventTrain4, BuildEventTrain2, Bu BuildEventFloorSniffing, BuildEventSocialApproach, BuildEventSocialEscape, BuildEventApproachContact, \ BuildEventOralOralContact, BuildEventApproachRear, BuildEventGroup2, BuildEventGroup3, BuildEventGroup4, \ BuildEventOralGenitalContact, BuildEventStop, BuildEventMove, BuildEventGroup3MakeBreak, BuildEventGroup4MakeBreak, \ - BuildEventSideBySide, BuildEventSideBySideOpposite, BuildDataBaseIndex, \ + BuildEventSideBySide, BuildEventSideBySideOpposite, \ BuildEventOralSideSequence, CheckWrongAnimal, BuildEventDetection, BuildEventCenterPeripheryLocation, BuildEventNest4, \ BuildEventNest3, BuildEventGetAway, BuildEventOtherContact, BuildEventPassiveAnogenitalSniff, BuildEventRearCenterPeriphery from lmtanalysis.TaskLogger import TaskLogger @@ -136,8 +136,6 @@ def process(file, windowT=oneDay, minT=0, maxT=None, use_cache_load_detection_ca except: print("METADATA field already exists" , file) - BuildDataBaseIndex.buildDataBaseIndex(connection, force=False) - currentT = minT try: @@ -172,7 +170,7 @@ def process(file, windowT=oneDay, minT=0, maxT=None, use_cache_load_detection_ca flushEventTimeLineCache() - + connection.close() chronoFullBatch.printTimeInS() print("*** ALL JOBS DONE ***") diff --git a/EMT/EMT_scripts/Rebuild_Huddling_events_script.py b/EMT/EMT_scripts/Rebuild_Huddling_events_script.py index da59cecc80d58f35221c52b1ccdb9feb81259139..c4a6cd4a296c1b813dc595eac642b703b03a3234 100644 --- a/EMT/EMT_scripts/Rebuild_Huddling_events_script.py +++ b/EMT/EMT_scripts/Rebuild_Huddling_events_script.py @@ -6,24 +6,19 @@ ################################################################################################### import argparse import sqlite3 -from pathlib import Path from psutil import virtual_memory - import traceback from lmtanalysis.Animal import * from lmtanalysis.Event import * from lmtanalysis.Measure import * from lmtanalysis.Util import getNumberOfFrames -from lmtanalysis import BuildEventHuddling, BuildEventHuddling_oldv, BuildEventHuddling_parallel, BuildDataBaseIndex +from lmtanalysis import BuildEventHuddling, BuildEventHuddling_oldv, BuildEventHuddling_parallel from lmtanalysis.TaskLogger import TaskLogger -from lmtanalysis.EventTimeLineCache import flushEventTimeLineCache,\ - disableEventTimeLineCache +from lmtanalysis.EventTimeLineCache import flushEventTimeLineCache, disableEventTimeLineCache from lmtanalysis.AnimalType import AnimalType -USE_CACHE_LOAD_DETECTION_CACHE = True - class FileProcessException(Exception): pass @@ -41,35 +36,29 @@ def processTimeWindow(file, connection, currentMinT , currentMaxT, mode="new"): animalPool = None flushEventTimeLineCache() - if (USE_CACHE_LOAD_DETECTION_CACHE): - print("Caching load of animal detection...") - animalPool = AnimalPool() - animalPool.loadAnimals(connection) - animalPool.loadDetection(start = currentMinT, end = currentMaxT) - print("Caching load of animal detection done.") - - chrono = Chronometer(str(BuildEventHuddling)) - if "old" in mode.lower(): - BuildEventHuddling_oldv.reBuildEvent(connection, file, - tmin=currentMinT, - tmax=currentMaxT, - pool = animalPool, - animalType = AnimalType.MOUSE) - elif "new" in mode.lower(): - BuildEventHuddling.reBuildEvent(connection, file, - tmin=currentMinT, - tmax=currentMaxT, - pool = animalPool, - animalType = AnimalType.MOUSE) - elif "parallel" in mode.lower(): - BuildEventHuddling_parallel.reBuildEvent(connection, file, - tmin=currentMinT, - tmax=currentMaxT, - pool = animalPool, - animalType = AnimalType.MOUSE) - else: - raise NotImplementedError("This mode does not exist. Use 'old', 'new' or 'parallel'") - chrono.printTimeInS() + + chrono = Chronometer(str(BuildEventHuddling)) + if "old" in mode.lower(): + BuildEventHuddling_oldv.reBuildEvent(connection, file, + tmin=currentMinT, + tmax=currentMaxT, + pool = animalPool, + animalType = AnimalType.MOUSE) + elif "new" in mode.lower(): + BuildEventHuddling.reBuildEvent(connection, file, + tmin=currentMinT, + tmax=currentMaxT, + pool = animalPool, + animalType = AnimalType.MOUSE) + elif "parallel" in mode.lower(): + BuildEventHuddling_parallel.reBuildEvent(connection, file, + tmin=currentMinT, + tmax=currentMaxT, + pool = animalPool, + animalType = AnimalType.MOUSE) + else: + raise NotImplementedError("This mode does not exist. Use 'old', 'new' or 'parallel'") + chrono.printTimeInS() def process(file, mode="new", windowT=oneDay, minT=0, maxT=None): @@ -89,9 +78,6 @@ def process(file, mode="new", windowT=oneDay, minT=0, maxT=None): except: print("METADATA field already exists" , file) - # Build Index - BuildDataBaseIndex.buildDataBaseIndex(connection, force=False) - currentT = minT try: @@ -124,6 +110,10 @@ def process(file, mode="new", windowT=oneDay, minT=0, maxT=None): raise FileProcessException() + flushEventTimeLineCache() + connection.close() + print("*** ALL JOBS DONE ***") + if __name__ == "__main__": @@ -160,6 +150,4 @@ if __name__ == "__main__": except FileProcessException: print ("STOP PROCESSING FILE ", file , file=sys.stderr) - flushEventTimeLineCache() - chronoFullBatch.printTimeInS() - print("*** ALL JOBS DONE ***") \ No newline at end of file + chronoFullBatch.printTimeInS() \ No newline at end of file diff --git a/EMT/EMT_scripts/Rebuild_SAP_events_script.py b/EMT/EMT_scripts/Rebuild_SAP_events_script.py index acedfca3651ba796d59853ce6ff5025779c96943..3fb5b73022f9c3e7d8463804436cc6f4bac5ba1c 100644 --- a/EMT/EMT_scripts/Rebuild_SAP_events_script.py +++ b/EMT/EMT_scripts/Rebuild_SAP_events_script.py @@ -6,19 +6,16 @@ ################################################################################################### import argparse import sqlite3 -from pathlib import Path from psutil import virtual_memory - import traceback from lmtanalysis.Animal import * from lmtanalysis.Event import * from lmtanalysis.Measure import * from lmtanalysis.Util import getNumberOfFrames -from lmtanalysis import BuildEventSAP, BuildEventSAP_oldv, BuildEventSAP_parallel, BuildDataBaseIndex +from lmtanalysis import BuildEventSAP, BuildEventSAP_oldv, BuildEventSAP_parallel from lmtanalysis.TaskLogger import TaskLogger -from lmtanalysis.EventTimeLineCache import flushEventTimeLineCache,\ - disableEventTimeLineCache +from lmtanalysis.EventTimeLineCache import flushEventTimeLineCache, disableEventTimeLineCache from lmtanalysis.AnimalType import AnimalType @@ -41,35 +38,28 @@ def processTimeWindow(file, connection, currentMinT , currentMaxT, mode="new"): animalPool = None flushEventTimeLineCache() - if (USE_CACHE_LOAD_DETECTION_CACHE): - print("Caching load of animal detection...") - animalPool = AnimalPool() - animalPool.loadAnimals(connection) - animalPool.loadDetection(start = currentMinT, end = currentMaxT) - print("Caching load of animal detection done.") - - chrono = Chronometer(str(BuildEventSAP)) - if "old" in mode.lower(): - BuildEventSAP_oldv.reBuildEvent(connection, file, - tmin=currentMinT, - tmax=currentMaxT, - pool = animalPool, - animalType = AnimalType.MOUSE) - elif "new" in mode.lower(): - BuildEventSAP.reBuildEvent(connection, file, - tmin=currentMinT, - tmax=currentMaxT, - pool = animalPool, - animalType = AnimalType.MOUSE) - elif "parallel" in mode.lower(): - BuildEventSAP_parallel.reBuildEvent(connection, file, - tmin=currentMinT, - tmax=currentMaxT, - pool = animalPool, - animalType = AnimalType.MOUSE) - else: - raise NotImplementedError("This mode does not exist. Use 'old', 'new' or 'parallel'") - chrono.printTimeInS() + chrono = Chronometer(str(BuildEventSAP)) + if "old" in mode.lower(): + BuildEventSAP_oldv.reBuildEvent(connection, file, + tmin=currentMinT, + tmax=currentMaxT, + pool = animalPool, + animalType = AnimalType.MOUSE) + elif "new" in mode.lower(): + BuildEventSAP.reBuildEvent(connection, file, + tmin=currentMinT, + tmax=currentMaxT, + pool = animalPool, + animalType = AnimalType.MOUSE) + elif "parallel" in mode.lower(): + BuildEventSAP_parallel.reBuildEvent(connection, file, + tmin=currentMinT, + tmax=currentMaxT, + pool = animalPool, + animalType = AnimalType.MOUSE) + else: + raise NotImplementedError("This mode does not exist. Use 'old', 'new' or 'parallel'") + chrono.printTimeInS() def process(file, mode="new", windowT=oneDay, minT=0, maxT=None): @@ -89,9 +79,6 @@ def process(file, mode="new", windowT=oneDay, minT=0, maxT=None): except: print("METADATA field already exists" , file) - # Build Index - BuildDataBaseIndex.buildDataBaseIndex(connection, force=False) - currentT = minT try: @@ -124,6 +111,10 @@ def process(file, mode="new", windowT=oneDay, minT=0, maxT=None): raise FileProcessException() + flushEventTimeLineCache() + connection.close() + print("*** ALL JOBS DONE ***") + if __name__ == "__main__": @@ -160,6 +151,4 @@ if __name__ == "__main__": except FileProcessException: print ("STOP PROCESSING FILE ", file , file=sys.stderr) - flushEventTimeLineCache() chronoFullBatch.printTimeInS() - print("*** ALL JOBS DONE ***") \ No newline at end of file diff --git a/EMT/EMT_scripts/Rebuild_WallJump_events_script.py b/EMT/EMT_scripts/Rebuild_WallJump_events_script.py index e3b13be29cc0071040d8c83d98444f1a1ee8f44d..b3ab57d810938194327f0ca45ea065b3bdd1f5cb 100644 --- a/EMT/EMT_scripts/Rebuild_WallJump_events_script.py +++ b/EMT/EMT_scripts/Rebuild_WallJump_events_script.py @@ -6,19 +6,16 @@ ################################################################################################### import argparse import sqlite3 -from pathlib import Path from psutil import virtual_memory - import traceback from lmtanalysis.Animal import * from lmtanalysis.Event import * from lmtanalysis.Measure import * from lmtanalysis.Util import getNumberOfFrames -from lmtanalysis import BuildEventWallJump, BuildEventWallJump_oldv, BuildEventWallJump_parallel, BuildDataBaseIndex +from lmtanalysis import BuildEventWallJump, BuildEventWallJump_oldv, BuildEventWallJump_parallel from lmtanalysis.TaskLogger import TaskLogger -from lmtanalysis.EventTimeLineCache import flushEventTimeLineCache,\ - disableEventTimeLineCache +from lmtanalysis.EventTimeLineCache import flushEventTimeLineCache, disableEventTimeLineCache from lmtanalysis.AnimalType import AnimalType @@ -41,35 +38,28 @@ def processTimeWindow(file, connection, currentMinT , currentMaxT, mode="new"): animalPool = None flushEventTimeLineCache() - if (USE_CACHE_LOAD_DETECTION_CACHE): - print("Caching load of animal detection...") - animalPool = AnimalPool() - animalPool.loadAnimals(connection) - animalPool.loadDetection(start = currentMinT, end = currentMaxT) - print("Caching load of animal detection done.") - - chrono = Chronometer(str(BuildEventWallJump)) - if "old" in mode.lower(): - BuildEventWallJump_oldv.reBuildEvent(connection, file, - tmin=currentMinT, - tmax=currentMaxT, - pool = animalPool, - animalType = AnimalType.MOUSE) - elif "new" in mode.lower(): - BuildEventWallJump.reBuildEvent(connection, file, - tmin=currentMinT, - tmax=currentMaxT, - pool = animalPool, - animalType = AnimalType.MOUSE) - elif "parallel" in mode.lower(): - BuildEventWallJump_parallel.reBuildEvent(connection, file, - tmin=currentMinT, - tmax=currentMaxT, - pool = animalPool, - animalType = AnimalType.MOUSE) - else: - raise NotImplementedError("This mode does not exist. Use 'old', 'new' or 'parallel'") - chrono.printTimeInS() + chrono = Chronometer(str(BuildEventWallJump)) + if "old" in mode.lower(): + BuildEventWallJump_oldv.reBuildEvent(connection, file, + tmin=currentMinT, + tmax=currentMaxT, + pool = animalPool, + animalType = AnimalType.MOUSE) + elif "new" in mode.lower(): + BuildEventWallJump.reBuildEvent(connection, file, + tmin=currentMinT, + tmax=currentMaxT, + pool = animalPool, + animalType = AnimalType.MOUSE) + elif "parallel" in mode.lower(): + BuildEventWallJump_parallel.reBuildEvent(connection, file, + tmin=currentMinT, + tmax=currentMaxT, + pool = animalPool, + animalType = AnimalType.MOUSE) + else: + raise NotImplementedError("This mode does not exist. Use 'old', 'new' or 'parallel'") + chrono.printTimeInS() def process(file, mode="new", windowT=oneDay, minT=0, maxT=None): @@ -89,9 +79,6 @@ def process(file, mode="new", windowT=oneDay, minT=0, maxT=None): except: print("METADATA field already exists" , file) - # Build Index - BuildDataBaseIndex.buildDataBaseIndex(connection, force=False) - currentT = minT try: @@ -124,6 +111,9 @@ def process(file, mode="new", windowT=oneDay, minT=0, maxT=None): raise FileProcessException() + flushEventTimeLineCache() + connection.close() + print("*** ALL JOBS DONE ***") if __name__ == "__main__": @@ -160,6 +150,4 @@ if __name__ == "__main__": except FileProcessException: print ("STOP PROCESSING FILE ", file , file=sys.stderr) - flushEventTimeLineCache() - chronoFullBatch.printTimeInS() - print("*** ALL JOBS DONE ***") \ No newline at end of file + chronoFullBatch.printTimeInS() \ No newline at end of file diff --git a/EMT/lmtanalysis/Animal.py b/EMT/lmtanalysis/Animal.py index 888d145184e29ff7f301ade81dcab6cd2696ecc6..6143da80693e646c36e80743c54b0fcd789b35df 100644 --- a/EMT/lmtanalysis/Animal.py +++ b/EMT/lmtanalysis/Animal.py @@ -3,37 +3,28 @@ Created on 7 sept. 2017 @author: Fab ''' -from lmtanalysis.Detection import * #matplotlib fix for mac (uncomment if needed) #matplotlib.use('TkAgg' ) - -import matplotlib.pyplot as plt -from lmtanalysis.Chronometer import * import matplotlib as mpl +import matplotlib.pyplot as plt +import matplotlib.patches as mpatches +import matplotlib.ticker as ticker import numpy as np import pandas as pd from collections import defaultdict -from mpl_toolkits.mplot3d import * -import matplotlib.ticker import math -import time -from lmtanalysis.Measure import * +import sqlite3 +from time import sleep -from statistics import * -#from scipy.spatial import distance -#from scipy.ndimage.measurements import standard_deviation -from statistics import mean +from lmtanalysis.Measure import * +from lmtanalysis.Detection import * +from lmtanalysis.Chronometer import * from lmtanalysis.Event import EventTimeLine from lmtanalysis.Point import Point from lmtanalysis.Mask import Mask -from lmtanalysis.Util import * -import matplotlib.patches as mpatches -from lxml import etree -import matplotlib.ticker as ticker -#from lmtanalysis.Util import convert_to_d_h_m_s, getDatetimeFromFrame, mute_prints -from pickle import NONE +from lmtanalysis.Util import getAllEvents, getDatetimeFromFrame, mute_prints, convert_to_d_h_m_s from lmtanalysis.AnimalType import AnimalType from lmtanalysis.ParametersMouse import ParametersMouse from lmtanalysis.ParametersRat import ParametersRat @@ -41,9 +32,6 @@ from lmtanalysis.ParametersRat import ParametersRat idAnimalColor = [ None, "red","green","blue","orange"] -from enum import Enum - - def getAnimalColor( animalId ): return idAnimalColor[ animalId % 5 ] @@ -124,7 +112,6 @@ class Animal(): if self.verbose: print( query ) - print( self.conn ) cursor.execute( query ) rows = cursor.fetchall() @@ -1047,7 +1034,16 @@ class Animal(): query = "SELECT DATA FROM DETECTION WHERE ANIMALID={} AND FRAMENUMBER={}".format( self.baseId , t ) cursor = self.conn.cursor() - cursor.execute( query ) + + retry = True + while retry: + try: + cursor.execute( query ) + except sqlite3.OperationalError: + sleep(0.1) + continue + else: + retry = False rows = cursor.fetchall() cursor.close() diff --git a/EMT/lmtanalysis/BuildEventHuddling.py b/EMT/lmtanalysis/BuildEventHuddling.py index 1016094b5c103a5de3ffaa2ff04b7f10ea890393..43cf48b89675b868d34395fb44d3e0699ab55cd5 100644 --- a/EMT/lmtanalysis/BuildEventHuddling.py +++ b/EMT/lmtanalysis/BuildEventHuddling.py @@ -26,11 +26,10 @@ def flush( connection ): def reBuildEvent( connection, file, tmin=None, tmax=None, pool = None , animalType = None, showGraph = False): ''' use the pool provided or create it''' - if ( pool == None ): - pool = AnimalPool( ) - pool.loadAnimals( connection ) - #pool.loadDetection( start = tmin, end = tmax ) - + if (pool == None): + pool = AnimalPool() + pool.loadAnimals(connection) + pool.loadDetection(start = tmin, end = tmax) for idAnimalA in pool.animalDictionary: diff --git a/EMT/lmtanalysis/BuildEventHuddling_parallel.py b/EMT/lmtanalysis/BuildEventHuddling_parallel.py index 3697f518e3ac0f159c0a24e6b8b793d07d44696e..ea6d6738b9d5ca60c2d52318841cd860390f8545 100644 --- a/EMT/lmtanalysis/BuildEventHuddling_parallel.py +++ b/EMT/lmtanalysis/BuildEventHuddling_parallel.py @@ -28,6 +28,7 @@ def computeHuddling(sqlite_file, idAnimalA, tmin=None, tmax=None): connection = sqlite3.connect(sqlite_file) pool = AnimalPool() pool.loadAnimals(connection) + pool.loadDetection(start = tmin, end = tmax, idAnimal=idAnimalA) animal = pool.animalDictionary[idAnimalA] huddlingTimeLine = EventTimeLine(connection, "Huddling", idAnimalA, minFrame=tmin, maxFrame=tmax, loadEvent=False) @@ -53,14 +54,15 @@ def computeHuddling(sqlite_file, idAnimalA, tmin=None, tmax=None): huddlingTimeLine.reBuildWithDictionary(result) huddlingTimeLine.endRebuildEventTimeLine(connection) + connection.close() return result def reBuildEvent(connection, file, tmin=None, tmax=None, pool = None , animalType = None, showGraph = False): # ''' use the pool provided or create it''' - if ( pool == None ): - pool = AnimalPool( ) - pool.loadAnimals( connection ) + if (pool == None): + pool = AnimalPool() + pool.loadAnimals(connection) processes = [] for idAnimalA in pool.animalDictionary: diff --git a/EMT/lmtanalysis/BuildEventSAP.py b/EMT/lmtanalysis/BuildEventSAP.py index b34986788c9676701d63624981c633beba8235e2..d895a77d4a13c3a00a637c0efe55d03e5d15eb13 100644 --- a/EMT/lmtanalysis/BuildEventSAP.py +++ b/EMT/lmtanalysis/BuildEventSAP.py @@ -89,13 +89,13 @@ def computeMetrics(image, r = 9, debug = False): return [I1, eccentricity, length] -def reBuildEvent( connection, file, tmin=None, tmax=None, pool = None , animalType = None, showGraph = False ): +def reBuildEvent(connection, file, tmin=None, tmax=None, pool = None , animalType = None, showGraph = False): ''' use the pool provided or create it''' - if ( pool == None ): - pool = AnimalPool( ) - pool.loadAnimals( connection ) - pool.loadDetection( start = tmin, end = tmax, lightLoad = True ) + if (pool == None): + pool = AnimalPool() + pool.loadAnimals(connection) + pool.loadDetection( start = tmin, end = tmax) ''' Animal A is stopped (built-in event): diff --git a/EMT/lmtanalysis/BuildEventSAP_parallel.py b/EMT/lmtanalysis/BuildEventSAP_parallel.py index d48cd5590140cd96c16495b3151088d525850654..b572715f2485e27e58ac405c87d77d2ee88e7732 100644 --- a/EMT/lmtanalysis/BuildEventSAP_parallel.py +++ b/EMT/lmtanalysis/BuildEventSAP_parallel.py @@ -99,7 +99,7 @@ def computeSAP(sqlite_file, idAnimalA, tmin=None, tmax=None): connection = sqlite3.connect(sqlite_file) pool = AnimalPool() pool.loadAnimals(connection) - pool.loadDetection(start = tmin, end = tmax, lightLoad = True, idAnimal=idAnimalA) + pool.loadDetection(start = tmin, end = tmax, idAnimal=idAnimalA) animal = pool.animalDictionary[idAnimalA] SAPTimeLine = EventTimeLine(connection, "SAP", animal.baseId, minFrame=tmin, maxFrame=tmax, loadEvent=False) @@ -140,6 +140,7 @@ def computeSAP(sqlite_file, idAnimalA, tmin=None, tmax=None): SAPTimeLine.reBuildWithDictionary(result) SAPTimeLine.endRebuildEventTimeLine(connection) + connection.close() return result def reBuildEvent(connection, file, tmin=None, tmax=None, pool = None , animalType = None, showGraph = False): diff --git a/EMT/lmtanalysis/BuildEventWallJump.py b/EMT/lmtanalysis/BuildEventWallJump.py index 4199c149e138df217b947bff621f81e0b802bea7..459a8ff3dc80b456b521c84dd541dd4578d74efc 100644 --- a/EMT/lmtanalysis/BuildEventWallJump.py +++ b/EMT/lmtanalysis/BuildEventWallJump.py @@ -80,7 +80,7 @@ def reBuildEvent( connection, file, tmin=None, tmax=None, pool = None, animalTyp if (pool == None): pool = AnimalPool() pool.loadAnimals(connection) - # pool.loadDetection(start = tmin, end = tmax, lightLoad = True) + pool.loadDetection(start = tmin, end = tmax) tmin = 0 if tmin is None else tmin tmax = getNumberOfFrames(file) if tmax is None else tmax diff --git a/EMT/lmtanalysis/BuildEventWallJump_parallel.py b/EMT/lmtanalysis/BuildEventWallJump_parallel.py index 9466c2667e7a4d9e2e3d4731d4f5056610eb0b63..0b63463248e57bb422218443b8746b0b80317774 100644 --- a/EMT/lmtanalysis/BuildEventWallJump_parallel.py +++ b/EMT/lmtanalysis/BuildEventWallJump_parallel.py @@ -3,6 +3,7 @@ Created on 6 sept. 2017 @author: Fab ''' +import sqlite3 import numpy as np import skimage.morphology as skm from multiprocessing import Process @@ -83,7 +84,7 @@ def computeWallJump(sqlite_file, idAnimalA, tmin=None, tmax=None): connection = sqlite3.connect(sqlite_file) pool = AnimalPool() pool.loadAnimals(connection) - pool.loadDetection(start = tmin, end = tmax, lightLoad = True, idAnimal=idAnimalA) + pool.loadDetection(start = tmin, end = tmax, idAnimal=idAnimalA) animal = pool.animalDictionary[idAnimalA] JumpWallTimeLine = EventTimeLine(connection, "WallJump", animal.baseId, None, None, None, loadEvent=False) result={} @@ -122,12 +123,16 @@ def computeWallJump(sqlite_file, idAnimalA, tmin=None, tmax=None): JumpWallTimeLine.reBuildWithDictionary(result) JumpWallTimeLine.endRebuildEventTimeLine(connection) + connection.close() + return result def reBuildEvent( connection, file, tmin=None, tmax=None, pool = None, animalType = None, showGraph = False ): - pool = AnimalPool() - pool.loadAnimals(connection) + ''' use the pool provided or create it''' + if (pool == None): + pool = AnimalPool() + pool.loadAnimals(connection) eventName = "WallJump" print (eventName) diff --git a/EMT/lmtanalysis/BuildEventWaterPoint.py b/EMT/lmtanalysis/BuildEventWaterPoint.py index 3f83f01df9f136c1293c09a704ad9cf20e55502b..b9bcefab8bccb4e2656ce71551120536ee7522df 100644 --- a/EMT/lmtanalysis/BuildEventWaterPoint.py +++ b/EMT/lmtanalysis/BuildEventWaterPoint.py @@ -30,10 +30,10 @@ def reBuildEvent(connection, file, tmin=None, tmax=None, pool = None, animalType parameters = getAnimalTypeParameters( animalType ) ''' use the pool provided or create it''' - if ( pool == None ): - pool = AnimalPool( ) - pool.loadAnimals( connection ) - pool.loadDetection( start = tmin, end = tmax, lightLoad=True ) + if (pool == None): + pool = AnimalPool() + pool.loadAnimals(connection) + pool.loadDetection(start = tmin, end = tmax) ''' Event Water Zone - the animal is in the zone around the water source diff --git a/EMT/lmtanalysis/Event.py b/EMT/lmtanalysis/Event.py index c2cd08def488db7870f0d09a8c39f7bc62ecd3c1..3b22e23832677550aceb74a2ab9fe9c24e597256 100644 --- a/EMT/lmtanalysis/Event.py +++ b/EMT/lmtanalysis/Event.py @@ -3,22 +3,20 @@ Created on 6 sept. 2017 @author: Fab ''' -import sqlite3 import unittest -from time import * -from lmtanalysis.Chronometer import Chronometer -import matplotlib #matplotlib fix for mac #matplotlib.use('TkAgg') import matplotlib.pyplot as plt import numpy as np -from lmtanalysis.Measure import * import sys import json from numpy import NaN +from lmtanalysis.Chronometer import Chronometer +from lmtanalysis.Measure import * + class Event: ''' an event represent the interval of frame where the event is diff --git a/EMT/lmtanalysis/Util.py b/EMT/lmtanalysis/Util.py index 570ddc6558e81c96fd07a15d757b562a3c169d7e..feeec5e5b5c13679a6de108473bcfbc776907446 100644 --- a/EMT/lmtanalysis/Util.py +++ b/EMT/lmtanalysis/Util.py @@ -10,7 +10,7 @@ import time import sqlite3 import datetime import contextlib -from random import randrange, random +from random import random import string diff --git a/EMT/setup.py b/EMT/setup.py index afed539da1143266cfb761817182c7e90f074d9f..f8af4fcfb1e2bb8eb035e6f6ff85ee5867f92f7e 100644 --- a/EMT/setup.py +++ b/EMT/setup.py @@ -3,7 +3,7 @@ from setuptools import setup setup( name='lmtanalysis', - version='1.2.0', + version='1.2.1', description='A new LMT package under development', author='Raul Silva', author_email='raul-alfredo.de-sousa-silva@lis-lab.fr',