diff --git a/Marta/3MPTracker/.config/dotnet-tools.json b/Marta/3MPTracker/.config/dotnet-tools.json new file mode 100644 index 0000000..45b8703 --- /dev/null +++ b/Marta/3MPTracker/.config/dotnet-tools.json @@ -0,0 +1,12 @@ +{ + "version": 1, + "isRoot": true, + "tools": { + "bonsai.sgen": { + "version": "0.1.0-build230726", + "commands": [ + "bonsai.sgen" + ] + } + } +} \ No newline at end of file diff --git a/Marta/3MPTracker/.gitattributes b/Marta/3MPTracker/.gitattributes new file mode 100644 index 0000000..d2d3c41 --- /dev/null +++ b/Marta/3MPTracker/.gitattributes @@ -0,0 +1,4 @@ +* text=auto +*.cmd text eol=crlf +*.bat text eol=crlf +*.bonsai text \ No newline at end of file diff --git a/Marta/3MPTracker/.gitignore b/Marta/3MPTracker/.gitignore new file mode 100644 index 0000000..e152bdc --- /dev/null +++ b/Marta/3MPTracker/.gitignore @@ -0,0 +1,14 @@ +# Bonsai scripting files +.vs +.vscode +bin +obj +Packages +Data +data +*.bin +*.avi +*.dll +*.exe.settings +Bonsai.exe.WebView2 + diff --git a/Marta/3MPTracker/README.md b/Marta/3MPTracker/README.md new file mode 100644 index 0000000..a88627a --- /dev/null +++ b/Marta/3MPTracker/README.md @@ -0,0 +1,16 @@ +# BonFly + +## Setting up + +These should only need to be installed once on a fresh new system, and are not required if simply refreshing the install or deploying to a new folder. + + * Windows 10 + * [Visual Studio Code](https://code.visualstudio.com/) (recommended for editing code scripts and git commits) + * [.NET Framework 4.7.2 Developer Pack](https://dotnet.microsoft.com/download/dotnet-framework/thank-you/net472-developer-pack-offline-installer) (required for intellisense when editing code scripts) + * [Git for Windows](https://gitforwindows.org/) (recommended for cloning and manipulating this repository) + * [Visual C++ Redistributable for Visual Studio 2012](https://www.microsoft.com/en-us/download/details.aspx?id=30679) (native dependency for OpenCV) + * [FTDI CDM Driver 2.12.28](https://www.ftdichip.com/Drivers/CDM/CDM21228_Setup.zip) (serial port drivers for HARP devices) + * [Spinnaker SDK 1.29.0.5](https://www.flir.com/support-center/iis/machine-vision/downloads/spinnaker-sdk-download/spinnaker-sdk--download-files/#anchor4) (device drivers for FLIR cameras) + + +You can download the latest release of tensorflow.dll [here](https://www.tensorflow.org/install/lang_c#download_and_extract) and copy it inside your Extensions folder. You can click [here](https://github.com/bonsai-rx/sleap) for further instructions on install sleap in Bonsai. diff --git a/Marta/3MPTracker/bonsai/Bonsai.config b/Marta/3MPTracker/bonsai/Bonsai.config new file mode 100644 index 0000000..0e855d1 --- /dev/null +++ b/Marta/3MPTracker/bonsai/Bonsai.config @@ -0,0 +1,177 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Marta/3MPTracker/bonsai/Bonsai.exe b/Marta/3MPTracker/bonsai/Bonsai.exe new file mode 100644 index 0000000..c20e591 Binary files /dev/null and b/Marta/3MPTracker/bonsai/Bonsai.exe differ diff --git a/Marta/3MPTracker/bonsai/NuGet.config b/Marta/3MPTracker/bonsai/NuGet.config new file mode 100644 index 0000000..f1326cf --- /dev/null +++ b/Marta/3MPTracker/bonsai/NuGet.config @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/Marta/3MPTracker/bonsai/setup.cmd b/Marta/3MPTracker/bonsai/setup.cmd new file mode 100644 index 0000000..3c53f3a --- /dev/null +++ b/Marta/3MPTracker/bonsai/setup.cmd @@ -0,0 +1 @@ +powershell -ExecutionPolicy Bypass -File .\setup.ps1 \ No newline at end of file diff --git a/Marta/3MPTracker/bonsai/setup.ps1 b/Marta/3MPTracker/bonsai/setup.ps1 new file mode 100644 index 0000000..1a6b7e6 --- /dev/null +++ b/Marta/3MPTracker/bonsai/setup.ps1 @@ -0,0 +1,9 @@ +if (!(Test-Path "./Bonsai.exe")) { + Invoke-WebRequest "https://github.com/bonsai-rx/bonsai/releases/download/2.7.2/Bonsai.zip" -OutFile "temp.zip" + Move-Item -Path "NuGet.config" "temp.config" + Expand-Archive "temp.zip" -DestinationPath "." -Force + Move-Item -Path "temp.config" "NuGet.config" -Force + Remove-Item -Path "temp.zip" + Remove-Item -Path "Bonsai32.exe" +} +& .\Bonsai.exe --no-editor \ No newline at end of file diff --git a/Marta/3MPTracker/src/.gitignore b/Marta/3MPTracker/src/.gitignore new file mode 100644 index 0000000..dede6da --- /dev/null +++ b/Marta/3MPTracker/src/.gitignore @@ -0,0 +1,3 @@ +# Bonsai scripting files +*.bonsai.layout + diff --git a/Marta/3MPTracker/src/Bonfly_3MPTracker_V1.1.0_ReversedStimState.bonsai b/Marta/3MPTracker/src/Bonfly_3MPTracker_V1.1.0_ReversedStimState.bonsai new file mode 100644 index 0000000..669a77e --- /dev/null +++ b/Marta/3MPTracker/src/Bonfly_3MPTracker_V1.1.0_ReversedStimState.bonsai @@ -0,0 +1,3630 @@ + + + + + + + + + Path + E:\Charlie\Startle_Project\Datasets_Loom_Control_BlackOut\Tracked_081924 + + + + + \RawData + + + + + + + + + + + E:\Charlie\Startle_Project\Datasets_Loom_Control_BlackOut\Tracked_081924 + *.avi + AllDirectories + + + + + + + BonflyPaths + + + + Source1 + + + GetDirectory + from System.IO import Path + +@returns(str) +def process(value): + output = Path.GetDirectoryName(value) + return output + + + + 1 + + + + ThisPath + + + VideoPath + + + Avi2Csv + it.Replace(".avi", ".csv") + + + CsvPath + + + ThisPath + + + it.Replace("RawData", "PostProcessing") + + + GetDirectory + from System.IO import Path + +@returns(str) +def process(value): + output = Path.GetDirectoryName(value) + return output + + + + 1 + + + + PostProcessingPath + + + ThisPath + + + PostProcessingPath + + + VideoPath + + + CsvPath + + + VideoPath + + + + + + + + + Rename + new( +Item1 as RawDataPath, +Item2 as PostProcessingPath, +Item3 as VideoPath, +Item4 as StimCsvPath, +Item5 as FileName) + + + + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + OfflineAnalysis + + + + Source1 + + + + 1 + + + + ThisSessionPaths + + + ThisSessionPaths + + + VideoPath + + + + + + + + ThisSessionPaths + + + StimCsvPath + + + + + + + + + + + + Settings + + + + + + + + 1 + + + + + 1 + + + + ScalingFactor + + + + + + Size + + 128 + 128 + + + + + 1 + + + + FlyCenteredCropSize + + + + + + FileName + E:\Charlie\Startle_Project\Datasets_Loom_Control_BlackOut\Tracked_081924\RawData\FH3\CR-EmptyTNT-20Control_3BlackOut-Female-6days-FH3-CamB-2024-08-19T16_06_03.avi + + + + 1 + + + + InputVideoPath + + + + + + FileName + E:\Charlie\Startle_Project\Datasets_Loom_Control_BlackOut\Tracked_081924\RawData\FH3\CR-EmptyTNT-20Control_3BlackOut-Female-6days-FH3-CamB-2024-08-19T16_06_03.csv + + + + 1 + + + + InputStimCsvPath + + + + + + + true + + + + + 1 + + + + SaveVideo + + + + + + + 70 + + + + + 1 + + + + ArenaThreshold + + + + + + ModelFileName + Extensions\wBackground.frozen_graph.pb + + + + + + TrainingConfig + Extensions\wBackground.training_config.json + + + ColorConversion + + + + ScaleFactor + + + + PartMinConfidence + + + + + + + + true + + + + + + + new( +Item1 as ModelFileName, +Item2 as TrainingConfig, +Item3 as ColorConversion, +Item4 as ScaleFactor, +Item5 as PartMinConfience, +Item6 as EnableSleap) + + + + 1 + + + + SleapModelConfiguration + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + DataLoader + + + + InputStimCsvPath + + + + + + + + InputVideoPath + + + + + + + + + E:\Charlie\Startle_Project\Datasets_Loom_Control_BlackOut\Tracked_081924\RawData\FH3\CR-EmptyTNT-20Control_3BlackOut-Female-6days-FH3-CamA-2024-08-19T16_06_03.avi + 99999999 + 0 + Frames + false + true + + + + E:\Charlie\Startle_Project\Datasets_Loom_Control_BlackOut\Tracked_081924\RawData\FH3\CR-EmptyTNT-20Control_3BlackOut-Female-6days-FH3-CamA-2024-08-19T16_06_03.csv + %i + 1 + + + from System import Tuple +@returns(Tuple[int, int, int]) +def process(value): + if value == 0: + return Tuple.Create(1,0,0) + if value == 4: + return Tuple.Create(0,0,0) + if value == 1: + return Tuple.Create(1,1,0) + if value == 8: + return Tuple.Create(1,0,1) + if value == 5: + return Tuple.Create(0,1,0) + if value == 9: + return Tuple.Create(1,1,1) + if value == 12: + return Tuple.Create(0,0,1) + if value == 13: + return Tuple.Create(0,1,1) + + + Rename + new( +Item1 as Visual, +Item2 as Stim0, +Item3 as Stim1 +) + + + + + + + + + Index + + + + + + Rename + new( +Item1 as Stimuli, +Item2 as Video, +Item3 as FrameCount_Video +) + + + Video&Stimuli + + + + PT7S + + + + ArenaFeeds + + + + 1 + + + + + + + Background + + + + InputVideoPath + + + + + + + + + + + + + CalculateBackground + + + + + + + + 5000 + + + + + 1 + + + + NumberBackgroundFrames + + + + + + + E:\Charlie\Startle_Project\Datasets_Loom_Control_BlackOut\Tracked_081924\RawData\FH3\CR-EmptyTNT-20Control_3BlackOut-Female-6days-FH3-CamB-2024-08-19T16_06_03.avi + + + + + 1 + + + + FileName + + + FileName + + + + + + + + + E:\Charlie\Startle_Project\Datasets_Loom_Control_BlackOut\Tracked_081924\RawData\FH3\CR-EmptyTNT-20Control_3BlackOut-Female-6days-FH3-CamB-2024-08-19T16_06_03.avi + 99999999 + 0 + Frames + false + true + + + + + + + + + + + + Brightest + 0 + + + + NumberBackgroundFrames + + + + + + + + + 5000 + + + + + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + + + + + + + + + + + + + + + BackgroundImage + + + FindArenas + + + + Source1 + + + + + + + + + + + + + 82 + 255 + Binary + + + + + ConnectedComponent + ChainApproxNone + + 0 + 0 + + 290000 + 380000 + + + + + + + Centroid.X,Centroid.Y + + + + 1 + + + + + + + + + + + + + + + + + + ArenaROIs + + + CropBackgrounds + + + + ArenaROIs + + + + 1 + + + + + + + CropBackgroundArenas + + + + Source1 + + + + 1 + + + + ArenaDetection + + + ArenaDetection + + + Contour + + + Rect + + + X + + + + -3 + + + + Y + + + + -3 + + + + Width + + + + 6 + + + + Height + + + + 6 + + + + + + + ROIEroded + + + BackgroundImage + + + ROIEroded + + + + + + + + + + 873 + 32 + 698 + 701 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + + + + + + + + + + + + + + + + CroppedBackground + + + CreateArenaFeeds + + + + ArenaROIs + + + + 1 + + + + InputVideoPath + + + + + + + + TrackArenas + + + + + + + + E:\Charlie\Startle_Project\Datasets_Loom_Control_BlackOut\Tracked_081924\RawData\FH3\CR-EmptyTNT-20Control_3BlackOut-Female-6days-FH3-CamA-2024-08-19T16_06_03.avi + + + + + 1 + + + + FileName + + + CroppedBackground + + + + + + Source1 + + + + + + + + + CropCenter + + + + Source1 + + + + 1 + + + + This + + + This + + + Item1 + + + + 1 + + + + ThisCropBackground + + + This + + + Item2 + + + Contour + + + Rect + + + X + + + + -3 + + + + Y + + + + -3 + + + + Width + + + + 2 + + + + Height + + + + 2 + + + + + + + ROIEroded + + + Video&Stimuli + + + Video + + + ROIEroded + + + + + + + + + Item1 + + + + + 893 + 4 + 691 + 695 + + + + + ThisCropBackground + + + + + + + + + ThisCropBackground + + + + + + Item2 + + + Stimuli + + + ArenaMask + + + + BackgroundImage + + + This + + + + + + + + + Item1 + + + + + 896 + 7 + 685 + 689 + + + + + This + + + Item2 + + + Contour + + + + 1 + -1 + + + + + + + + ROIEroded + + + + + + + + + + 691 + 695 + + Constant + + 0 + 0 + 0 + 0 + + + 3 + 3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + Item2 + + + + + + new( +Item1 as RawFrame, +Item2 as BackgroundSubtractedFrame, +Item3 as RawBackground, +Item4 as Stimuli, +Item5 as MaskedArena) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ArenaFeeds + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + AnalysisPipeline + + + + ArenaFeeds + + + + 1 + + + + + + + + + + ProcessSingleArenaFrames + + + + Source1 + + + Data + + + + Data + + + Index + + + + 1 + + + + ArenaIndex + + + Data + + + Value + + + + + + ArenaVideoStream + + + CentroidTracking + + + + ArenaVideoStream + + + BackgroundSubtractedFrame + + + + 76 + 255 + Binary + + + + + External + ChainApproxNone + + 0 + 0 + + 3 + + + + + + + + + + + Centroid + + + + 21 + 255 + Binary + + + + + External + ChainApproxNone + + 0 + 0 + + 3 + + + + + + + + + + + Centroid + + + + + + Rename + new( +Item1 as SoftCentroid, +Item2 as HardCentroid) + + + PickBestCentroid + it.SoftCentroid.X > 0 ? it.SoftCentroid : it.HardCentroid + + + BestCentroid + + + BestCentroid + + + ArenaVideoStream + + + RawFrame.RegionOfInterest + + + + + + new( +Item1.X / Item2.Width as X, +Item1.Y / Item2.Height as Y +) + + + + + + + X,Y + + + + 0.897631764 + 0.7035003 + + + + NormalizedBestCentroid + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + PixelChange + + + + ArenaVideoStream + + + BackgroundSubtractedFrame + + + + 1 + 1 + 10 + Binary + Dark + + + + + External + ChainApproxNone + + 0 + 0 + + 3 + + + + + + 1 + -1 + + + + + + + PixelChange + + + + + + + + + + + + + + + + Logging + + + + SaveArena + + + + ArenaVideoStream + + + MaskedArena + + + ThisSessionPaths + + + PostProcessingPath + + + + \Arenas + + + + ThisSessionPaths + + + FileName + + + ArenaIndex + + + + + + {0}/{1}_fly{2}.png + Item1,Item2,Item3 + + + + + + + + + Item1 + + + + E:\Charlie\Startle_Project\Datasets_Loom_Control_BlackOut\Tracked_081924\PostProcessing\Arenas/CR-EmptyTNT-20Control_3BlackOut-Female-6days-FH3-CamA-2024-08-19T16_06_03_fly2.png + None + + + + + 1 + + + + + + + + + + + + + + + + + + + + + + + + Track + + + + ThisSessionPaths + + + PostProcessingPath + + + + \Tracked + + + + ThisSessionPaths + + + FileName + + + ArenaIndex + + + + + + {0}/{1}_fly{2}_tracked.csv + Item1,Item2,Item3 + + + + + + + + Video&Stimuli + + + FrameCount_Video + + + ArenaVideoStream + + + Stimuli.Visual,Stimuli.Stim0,Stimuli.Stim1 + + + NormalizedBestCentroid + + + PixelChange + + + + + + Header + new( +Item1 as FrameIndex, +Item2.Item1 as VisualStim, +Item2.Item2 as Stim0, +Item2.Item3 as Stim1, +Item3.X as NormalizedCentroidX, +Item3.Y as NormalizedCentroidY, +Item4 as PixelChange +) + + + E:\Charlie\Startle_Project\Datasets_Loom_Control_BlackOut\Tracked_081924\PostProcessing\Tracked/CR-EmptyTNT-20Control_3BlackOut-Female-6days-FH3-CamA-2024-08-19T16_06_03_fly2_tracked.csv + false + false + None + true + + + + + + + + + + + + + + + + + + + + + + + + + + + CropRaw + + + + ThisSessionPaths + + + PostProcessingPath + + + + \CropRaw + + + + ThisSessionPaths + + + FileName + + + ArenaIndex + + + + + + {0}/{1}_fly{2}_crop.avi + Item1,Item2,Item3 + + + + + + + + CenteredVideo + + + + E:\Charlie\Startle_Project\Datasets_Loom_Control_BlackOut\Tracked_081924\PostProcessing\CropRaw/CR-EmptyTNT-20Control_3BlackOut-Female-6days-FH3-CamA-2024-08-19T16_06_03_fly2_crop.avi + None + true + false + FMP4 + 60 + + 0 + 0 + + NearestNeighbor + + + + + + + + + + + + + + + + + + + + + CropSubtract + + + + ThisSessionPaths + + + PostProcessingPath + + + + \CropSubtract + + + + ThisSessionPaths + + + FileName + + + ArenaIndex + + + + + + {0}/{1}_fly{2}_cropsub.avi + Item1,Item2,Item3 + + + + + + + + CenteredVideoBackSub + + + + E:\Charlie\Startle_Project\Datasets_Loom_Control_BlackOut\Tracked_081924\PostProcessing\CropSubtract/CR-EmptyTNT-20Control_3BlackOut-Female-6days-FH3-CamA-2024-08-19T16_06_03_fly2_cropsub.avi + None + true + false + FMP4 + 60 + + 0 + 0 + + NearestNeighbor + + + + + + + + + + + + + + + + + + + + + Pose + + + + ThisSessionPaths + + + PostProcessingPath + + + + \Pose + + + + ThisSessionPaths + + + FileName + + + ArenaIndex + + + + + + {0}/{1}_fly{2}_pose.csv + Item1,Item2,Item3 + + + + + + + + SleapOutput + + + + Video&Stimuli + + + FrameCount_Video + + + NormalizedBodyParts + + + + + + Header + new( +Item1 as FrameIndex, +Item2.ViewPoints.Left as Left, +Item2.ViewPoints.Right as Right, +Item2.ViewPoints.Top as Top, +Item2.BodyPoints.Head as Head, +Item2.BodyPoints.Thorax as Thorax, +Item2.BodyPoints.Abdomen as Abdomen, +Item2.BodyPoints.LeftWing as LeftWing, +Item2.BodyPoints.RightWing as RightWing +) + + + + + + + + + + + + + + E:\Charlie\Startle_Project\Datasets_Loom_Control_BlackOut\Tracked_081924\PostProcessing\Pose/CR-EmptyTNT-20Control_3BlackOut-Female-6days-FH3-CamA-2024-08-19T16_06_03_fly2_pose.csv + false + false + None + true + + + + + + + + + + + + + + + + + + + + SleapModelConfiguration + + + EnableSleap + + + + + + Source1 + + + + false + + + + + + + + + + + + + + + StimVideo + + + + ThisSessionPaths + + + PostProcessingPath + + + + \StimVideos + + + + ThisSessionPaths + + + FileName + + + ArenaIndex + + + + + + {0}/{1}_fly{2}.avi + Item1,Item2,Item3 + + + + + + + + ArenaVideoStream + + + BackgroundSubtractedFrame + + + MaskedArena + + + + + + + + + ArenaVideoStream + + + Stimuli.Visual,Stimuli.Stim0,Stimuli.Stim1 + + + + + + PaintEvent + +import clr +clr.AddReference("OpenCV.Net") +from OpenCV.Net import * +from math import sin, cos, pi + +font = None +def load(): + global font + font = Font(1,1) + +@returns(IplImage) +def process(value): + output = value.Item1.Clone() + image = value.Item1.Clone() + output = IplImage(image.Size, image.Depth, 3) + CV.CvtColor(image,output,ColorConversion.Gray2Bgr) + + visualState = value.Item2.Item1 + stim0State = value.Item2.Item2 + stim1State = value.Item2.Item3 + + if visualState == 1: + CV.Circle(output, Point(25, 25), 15, Scalar.Rgb(255, 255, 255), -1) + else: + CV.Circle(output, Point(25, 25), 15, Scalar.Rgb(32, 32, 32), -1) + + CV.PutText(output,'0',Point(43,24),font,Scalar.All(255)) + CV.PutText(output,'1',Point(43,38),font,Scalar.All(255)) + + if stim0State == 1: + CV.Circle(output, Point(60, 18), 5, Scalar.Rgb(255, 255, 255), -1) + else: + CV.Circle(output, Point(60, 18), 5, Scalar.Rgb(32, 32, 32), -1) + + if stim1State == 1: + CV.Circle(output, Point(60, 33), 5, Scalar.Rgb(255, 255, 255), -1) + else: + CV.Circle(output, Point(60, 33), 5, Scalar.Rgb(32, 32, 32), -1) + + + + return output + + + + + + + + 704 + 704 + + Linear + + + + + E:\Charlie\Startle_Project\Datasets_Loom_Control_BlackOut\Tracked_081924\PostProcessing\StimVideos/CR-EmptyTNT-20Control_3BlackOut-Female-6days-FH3-CamA-2024-08-19T16_06_03_fly2.avi + None + true + false + FMP4 + 60 + + 0 + 0 + + NearestNeighbor + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SaveVideo + + + + + + Source1 + + + + true + + + + + + + + + + + + + + + + + + + + + + + + + + + SleapTracking + + + + CenteredVideo + + + SleapModelConfiguration + + + + + + + + + + + + + Extensions\wBackground.frozen_graph.pb + Extensions\wBackground.training_config.json + + + + + + + PoseStream + + + CenteredVideo + + + RegionOfInterest + + + BestCentroid + + + + + + CropCorrection + Returns normalized XY +1.1 Centroid +1.2 pointA +1.3 pointB +2.1 Head +2.2 Thorax +2.3 Abdomen +2.4 Lwing +2.5 Rwing + +import clr +clr.AddReference("OpenCV.Net") +from OpenCV.Net import * +from System import Tuple, Math, Single + +@returns(Point2f) +def process(value): + cropMiddle = Point2f(value.Item1.Width / 2, value.Item1.Height / 2) + + flyCentroid = value.Item2 + + correction = flyCentroid - cropMiddle + + return correction + + + CropCorrection + + + PoseStream + + + NormalizedBodyParts + + + + Source1 + + + ViewPoints + + + + Source1 + + + + Left + + + + Normalizer + + + + Source1 + + + Position,Confidence + + + CropCorrection + + + ArenaVideoStream + + + RawFrame.RegionOfInterest + + + + + + NormalizeXY + Returns normalized XY +1.1 Centroid +1.2 pointA +1.3 pointB +2.1 Head +2.2 Thorax +2.3 Abdomen +2.4 Lwing +2.5 Rwing + +import clr +clr.AddReference("OpenCV.Net") +from OpenCV.Net import * +from System import Tuple, Math, Single + +@returns(Tuple[Point2f,float]) +def process(value): + position = value.Item1.Item1 + confidence = float(value.Item1.Item2) + correction = value.Item2 + arenaWidth = value.Item3.Width + arenaHeight = value.Item3.Height + + corrected = position + correction + + normalized = Point2f(corrected.X / arenaWidth, corrected.Y / arenaHeight) + + output = Tuple.Create(normalized, float(confidence)) + + return output + + + Rename + new( +Item1 as Position, +Item2 as Confidence +) + + + + + + + + + + + + + + + + + + Right + + + + Normalizer + + + + Source1 + + + Position,Confidence + + + CropCorrection + + + ArenaVideoStream + + + RawFrame.RegionOfInterest + + + + + + NormalizeXY + Returns normalized XY +1.1 Centroid +1.2 pointA +1.3 pointB +2.1 Head +2.2 Thorax +2.3 Abdomen +2.4 Lwing +2.5 Rwing + +import clr +clr.AddReference("OpenCV.Net") +from OpenCV.Net import * +from System import Tuple, Math, Single + +@returns(Tuple[Point2f,float]) +def process(value): + position = value.Item1.Item1 + confidence = float(value.Item1.Item2) + correction = value.Item2 + arenaWidth = value.Item3.Width + arenaHeight = value.Item3.Height + + corrected = position + correction + + normalized = Point2f(corrected.X / arenaWidth, corrected.Y / arenaHeight) + + output = Tuple.Create(normalized, float(confidence)) + + return output + + + Rename + new( +Item1 as Position, +Item2 as Confidence +) + + + + + + + + + + + + + + + + + + Top + + + + Normalizer + + + + Source1 + + + Position,Confidence + + + CropCorrection + + + ArenaVideoStream + + + RawFrame.RegionOfInterest + + + + + + NormalizeXY + Returns normalized XY +1.1 Centroid +1.2 pointA +1.3 pointB +2.1 Head +2.2 Thorax +2.3 Abdomen +2.4 Lwing +2.5 Rwing + +import clr +clr.AddReference("OpenCV.Net") +from OpenCV.Net import * +from System import Tuple, Math, Single + +@returns(Tuple[Point2f,float]) +def process(value): + position = value.Item1.Item1 + confidence = float(value.Item1.Item2) + correction = value.Item2 + arenaWidth = value.Item3.Width + arenaHeight = value.Item3.Height + + corrected = position + correction + + normalized = Point2f(corrected.X / arenaWidth, corrected.Y / arenaHeight) + + output = Tuple.Create(normalized, float(confidence)) + + return output + + + Rename + new( +Item1 as Position, +Item2 as Confidence +) + + + + + + + + + + + + + + + + + + + + Rename + new( +Item1 as Left, +Item2 as Right, +Item3 as Top) + + + + + + + + + + + + + + + + + + + + BodyPoints + + + + Source1 + + + + Head + + + + Normalizer + + + + Source1 + + + Position,Confidence + + + CropCorrection + + + ArenaVideoStream + + + RawFrame.RegionOfInterest + + + + + + NormalizeXY + Returns normalized XY +1.1 Centroid +1.2 pointA +1.3 pointB +2.1 Head +2.2 Thorax +2.3 Abdomen +2.4 Lwing +2.5 Rwing + +import clr +clr.AddReference("OpenCV.Net") +from OpenCV.Net import * +from System import Tuple, Math, Single + +@returns(Tuple[Point2f,float]) +def process(value): + position = value.Item1.Item1 + confidence = float(value.Item1.Item2) + correction = value.Item2 + arenaWidth = value.Item3.Width + arenaHeight = value.Item3.Height + + corrected = position + correction + + normalized = Point2f(corrected.X / arenaWidth, corrected.Y / arenaHeight) + + output = Tuple.Create(normalized, float(confidence)) + + return output + + + Rename + new( +Item1 as Position, +Item2 as Confidence +) + + + + + + + + + + + + + + + + + + Thorax + + + + Normalizer + + + + Source1 + + + Position,Confidence + + + CropCorrection + + + ArenaVideoStream + + + RawFrame.RegionOfInterest + + + + + + NormalizeXY + Returns normalized XY +1.1 Centroid +1.2 pointA +1.3 pointB +2.1 Head +2.2 Thorax +2.3 Abdomen +2.4 Lwing +2.5 Rwing + +import clr +clr.AddReference("OpenCV.Net") +from OpenCV.Net import * +from System import Tuple, Math, Single + +@returns(Tuple[Point2f,float]) +def process(value): + position = value.Item1.Item1 + confidence = float(value.Item1.Item2) + correction = value.Item2 + arenaWidth = value.Item3.Width + arenaHeight = value.Item3.Height + + corrected = position + correction + + normalized = Point2f(corrected.X / arenaWidth, corrected.Y / arenaHeight) + + output = Tuple.Create(normalized, float(confidence)) + + return output + + + Rename + new( +Item1 as Position, +Item2 as Confidence +) + + + + + + + + + + + + + + + + + + Abdomen + + + + Normalizer + + + + Source1 + + + Position,Confidence + + + CropCorrection + + + ArenaVideoStream + + + RawFrame.RegionOfInterest + + + + + + NormalizeXY + Returns normalized XY +1.1 Centroid +1.2 pointA +1.3 pointB +2.1 Head +2.2 Thorax +2.3 Abdomen +2.4 Lwing +2.5 Rwing + +import clr +clr.AddReference("OpenCV.Net") +from OpenCV.Net import * +from System import Tuple, Math, Single + +@returns(Tuple[Point2f,float]) +def process(value): + position = value.Item1.Item1 + confidence = float(value.Item1.Item2) + correction = value.Item2 + arenaWidth = value.Item3.Width + arenaHeight = value.Item3.Height + + corrected = position + correction + + normalized = Point2f(corrected.X / arenaWidth, corrected.Y / arenaHeight) + + output = Tuple.Create(normalized, float(confidence)) + + return output + + + Rename + new( +Item1 as Position, +Item2 as Confidence +) + + + + + + + + + + + + + + + + + + LeftWing + + + + Normalizer + + + + Source1 + + + Position,Confidence + + + CropCorrection + + + ArenaVideoStream + + + RawFrame.RegionOfInterest + + + + + + NormalizeXY + Returns normalized XY +1.1 Centroid +1.2 pointA +1.3 pointB +2.1 Head +2.2 Thorax +2.3 Abdomen +2.4 Lwing +2.5 Rwing + +import clr +clr.AddReference("OpenCV.Net") +from OpenCV.Net import * +from System import Tuple, Math, Single + +@returns(Tuple[Point2f,float]) +def process(value): + position = value.Item1.Item1 + confidence = float(value.Item1.Item2) + correction = value.Item2 + arenaWidth = value.Item3.Width + arenaHeight = value.Item3.Height + + corrected = position + correction + + normalized = Point2f(corrected.X / arenaWidth, corrected.Y / arenaHeight) + + output = Tuple.Create(normalized, float(confidence)) + + return output + + + Rename + new( +Item1 as Position, +Item2 as Confidence +) + + + + + + + + + + + + + + + + + + RightWing + + + + Normalizer + + + + Source1 + + + Position,Confidence + + + CropCorrection + + + ArenaVideoStream + + + RawFrame.RegionOfInterest + + + + + + NormalizeXY + Returns normalized XY +1.1 Centroid +1.2 pointA +1.3 pointB +2.1 Head +2.2 Thorax +2.3 Abdomen +2.4 Lwing +2.5 Rwing + +import clr +clr.AddReference("OpenCV.Net") +from OpenCV.Net import * +from System import Tuple, Math, Single + +@returns(Tuple[Point2f,float]) +def process(value): + position = value.Item1.Item1 + confidence = float(value.Item1.Item2) + correction = value.Item2 + arenaWidth = value.Item3.Width + arenaHeight = value.Item3.Height + + corrected = position + correction + + normalized = Point2f(corrected.X / arenaWidth, corrected.Y / arenaHeight) + + output = Tuple.Create(normalized, float(confidence)) + + return output + + + Rename + new( +Item1 as Position, +Item2 as Confidence +) + + + + + + + + + + + + + + + + + + + + Rename + new( +Item1 as Head, +Item2 as Thorax, +Item3 as Abdomen, +Item4 as LeftWing, +Item5 as RightWing +) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Rename + new( +Item1 as ViewPoints, +Item2 as BodyPoints) + + + + + + + + + + + + + + + NormalizedBodyParts + + + + + + + + + + + + + + + + + + + + + SleapModelConfiguration + + + EnableSleap + + + + + + Source1 + + + + + + + + + + + + + VisualizerOut + + + + CenteredVideo + + + + ArenaVideoStream + + + RawFrame + + + BestCentroid + + + + + + FlyCenteredCropSize + + + + + + + + + + 128 + 128 + + + 0 + 0 + 0 + 0 + + + + + CenteredVideo + + + + ArenaVideoStream + + + BackgroundSubtractedFrame + + + BestCentroid + + + + + + FlyCenteredCropSize + + + + + + + + + + 128 + 128 + + + 0 + 0 + 0 + 0 + + + + + CenteredVideoBackSub + + + + + + + + + + + + + + + + + + + + + + + Video&Stimuli + + + FrameCount_Video + + + Header + new(it as FrameCount_ArenaStream) + + + Stimuli + + + + + + ArenaIndex + + + + + + ThisSessionPaths + + + FileName + + + + + + Item1.Item2 + + + Item1.Item1.Item1 + + + Item1.Item1.Item2 + + + Item1.Item1.Item3 + + + Item2 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Visualizers + + + + Source1 + + + + + + Source1 + + + Item1 + + + + + + + 0 + + + + + + + + + + + + + + Item2 + + + + + + + + + Source1 + + + Item1 + + + + + + + 1 + + + + + + + + + + + + + + Item2 + + + + + + Item4.Visual,Item4.Stim0,Item4.Stim1 + + + + + 128 + 128 + + U8 + 3 + + 0 + 0 + 0 + 0 + + + + + + + + + + + + + + PaintLED + +import clr +clr.AddReference("OpenCV.Net") +from OpenCV.Net import * +from math import sin, cos, pi + +font = None +def load(): + global font + font = Font(2,2) + +@returns(IplImage) +def process(value): + output = value.Item2.Clone() + image = value.Item2.Clone() + output = IplImage(image.Size, image.Depth, 3) + CV.CvtColor(image,output,ColorConversion.Gray2Bgr) + + LoomState = value.Item1.Item1 + RedState = value.Item1.Item2 + GreenState = value.Item1.Item3 + + if RedState == 1: + CV.Circle(output, Point(64, 64), 55, Scalar.Rgb(204, 0, 0), -1) + + if GreenState == 1: + CV.Circle(output, Point(64, 64), 55, Scalar.Rgb(0, 204, 0), -1) + + if LoomState == 1: + CV.Circle(output, Point(64, 64), 40, Scalar.Rgb(255, 255, 255), -1) + else: + CV.Circle(output, Point(64, 64), 40, Scalar.Rgb(32, 32, 32), -1) + + return output + + + + + + + + + Source1 + + + Item1 + + + + + + + 2 + + + + + + + + + + + + + + Item2 + + + + + + + + + Source1 + + + Item1 + + + + + + + 3 + + + + + + + + + + + + + + Item2 + + + + + + Item2 + + + Item5 + + + + + + + + + Index + + + + 1 + + + + + + + Item1 + + + Item2 + + + Item3.FrameCount_ArenaStream + + + + + + TimeInfo + +import clr +clr.AddReference("OpenCV.Net") +from OpenCV.Net import * +from math import sin, cos, pi + +font = None +def load(): + global font + font = Font(1,1) + +@returns(IplImage) +def process(value): + output = value.Item1.Clone() + image = value.Item1.Clone() + output = IplImage(image.Size, image.Depth, 3) + CV.CvtColor(image,output,ColorConversion.Gray2Bgr) + + filenumber = 'File # ' + value.Item2.ToString() + CV.PutText(output,filenumber,Point(5,45),font,Scalar.All(255)) + + FrameNumber = '# ' + value.Item3.ToString() + CV.PutText(output,'Frame',Point(5,80),font,Scalar.All(255)) + CV.PutText(output,FrameNumber,Point(5,100),font,Scalar.All(255)) + + return output + + + + + + 3 + 2 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Marta/3MPTracker/src/Bonfly_3MPTracker_V1.1.1_ReversedStimState.bonsai b/Marta/3MPTracker/src/Bonfly_3MPTracker_V1.1.1_ReversedStimState.bonsai new file mode 100644 index 0000000..c16a2ba --- /dev/null +++ b/Marta/3MPTracker/src/Bonfly_3MPTracker_V1.1.1_ReversedStimState.bonsai @@ -0,0 +1,3760 @@ + + + + + + Initialize + + + + + 0 + + + + FileFinished + + + + + + + + + + + + + + Path + C:\Users\HugoMarques\Documents\Code\MyReps\cf.labs\Marta\3MPTracker\data + + + + + + + + + C:\Users\HugoMarques\Documents\Code\MyReps\cf.labs\Marta\3MPTracker\data + *.avi + AllDirectories + + + + Get Number of Files + + + + Source1 + + + Length + + + NumberOfFiles + + + + + + Item1 + + + + + + + + + + + + + + + + + + BonflyPaths + + + + Source1 + + + GetDirectory + from System.IO import Path + +@returns(str) +def process(value): + output = Path.GetDirectoryName(value) + return output + + + + 1 + + + + ThisPath + + + VideoPath + + + Avi2Csv + it.Replace(".avi", ".csv") + + + CsvPath + + + ThisPath + + + it.Replace("RawData", "PostProcessing") + + + GetDirectory + from System.IO import Path + +@returns(str) +def process(value): + output = Path.GetDirectoryName(value) + return output + + + + 1 + + + + PostProcessingPath + + + ThisPath + + + PostProcessingPath + + + VideoPath + + + CsvPath + + + VideoPath + + + + + + + + + Rename + new( +Item1 as RawDataPath, +Item2 as PostProcessingPath, +Item3 as VideoPath, +Item4 as StimCsvPath, +Item5 as FileName) + + + + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + OfflineAnalysis + + + + Source1 + + + + 1 + + + + ThisSessionPaths + + + ThisSessionPaths + + + VideoPath + + + + + + + + ThisSessionPaths + + + StimCsvPath + + + + + + + + + + + + Settings + + + + + + + + 1 + + + + + 1 + + + + ScalingFactor + + + + + + Size + + 128 + 128 + + + + + 1 + + + + FlyCenteredCropSize + + + + + + FileName + C:\Users\HugoMarques\Documents\Code\MyReps\cf.labs\Marta\3MPTracker\data\RawData\FH3\CR-EmptyTNT-20Control_3BlackOut-Female-4-5days-FH3-CamA-2024-07-19T11_34_57.avi + + + + 1 + + + + InputVideoPath + + + + + + FileName + C:\Users\HugoMarques\Documents\Code\MyReps\cf.labs\Marta\3MPTracker\data\RawData\FH3\CR-EmptyTNT-20Control_3BlackOut-Female-4-5days-FH3-CamA-2024-07-19T11_34_57.csv + + + + 1 + + + + InputStimCsvPath + + + + + + + true + + + + + 1 + + + + SaveVideo + + + + + + + 70 + + + + + 1 + + + + ArenaThreshold + + + + + + ModelFileName + Extensions\wBackground.frozen_graph.pb + + + + + + TrainingConfig + Extensions\wBackground.training_config.json + + + ColorConversion + + + + ScaleFactor + + + + PartMinConfidence + + + + + + + + true + + + + + + + new( +Item1 as ModelFileName, +Item2 as TrainingConfig, +Item3 as ColorConversion, +Item4 as ScaleFactor, +Item5 as PartMinConfience, +Item6 as EnableSleap) + + + + 1 + + + + SleapModelConfiguration + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + DataLoader + + + + InputStimCsvPath + + + + + + + + InputVideoPath + + + + + + + + + C:\Users\HugoMarques\Documents\Code\MyReps\cf.labs\Marta\3MPTracker\data\RawData\FH3\CR-EmptyTNT-20Control_3BlackOut-Female-4-5days-FH3-CamA-2024-07-19T11_34_57.avi + 99999999 + 0 + Frames + false + true + + + + C:\Users\HugoMarques\Documents\Code\MyReps\cf.labs\Marta\3MPTracker\data\RawData\FH3\CR-EmptyTNT-20Control_3BlackOut-Female-4-5days-FH3-CamA-2024-07-19T11_34_57.csv + %i + 1 + + + from System import Tuple +@returns(Tuple[int, int, int]) +def process(value): + if value == 0: + return Tuple.Create(1,0,0) + if value == 4: + return Tuple.Create(0,0,0) + if value == 1: + return Tuple.Create(1,1,0) + if value == 8: + return Tuple.Create(1,0,1) + if value == 5: + return Tuple.Create(0,1,0) + if value == 9: + return Tuple.Create(1,1,1) + if value == 12: + return Tuple.Create(0,0,1) + if value == 13: + return Tuple.Create(0,1,1) + + + Rename + new( +Item1 as Visual, +Item2 as Stim0, +Item3 as Stim1 +) + + + + + + + + + Index + + + + + + Rename + new( +Item1 as Stimuli, +Item2 as Video, +Item3 as FrameCount_Video +) + + + Video&Stimuli + + + + PT7S + + + + ArenaFeeds + + + + 1 + + + + + + + + + + Interval.TotalMilliseconds + + + + 10 + 10 + + + + + + + + + + + 0 + + + + FileFinished + + + Background + + + + InputVideoPath + + + + + + + + + + + + + CalculateBackground + + + + + + + + 5000 + + + + + 1 + + + + NumberBackgroundFrames + + + + + + + C:\Users\HugoMarques\Documents\Code\MyReps\cf.labs\Marta\3MPTracker\data\RawData\FH3\CR-EmptyTNT-20Control_3BlackOut-Female-4-5days-FH3-CamA-2024-07-19T11_34_57.avi + + + + + 1 + + + + FileName + + + FileName + + + + + + + + + C:\Users\HugoMarques\Documents\Code\MyReps\cf.labs\Marta\3MPTracker\data\RawData\FH3\CR-EmptyTNT-20Control_3BlackOut-Female-4-5days-FH3-CamA-2024-07-19T11_34_57.avi + 99999999 + 0 + Frames + false + true + + + + + + + + + + + + Brightest + 0 + + + + NumberBackgroundFrames + + + + + + + + + 5000 + + + + + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + + + + + + + + + + + + + + + BackgroundImage + + + FindArenas + + + + Source1 + + + + + + + + + + + + + 93 + 255 + Binary + + + + + ConnectedComponent + ChainApproxNone + + 0 + 0 + + 290000 + 380000 + + + + + + + Centroid.X,Centroid.Y + + + + 1 + + + + + + + + + + + + + + + + + + ArenaROIs + + + CropBackgrounds + + + + ArenaROIs + + + + 1 + + + + + + + CropBackgroundArenas + + + + Source1 + + + + 1 + + + + ArenaDetection + + + ArenaDetection + + + Contour + + + Rect + + + X + + + + -1 + + + + Y + + + + -1 + + + + Width + + + + 2 + + + + Height + + + + 2 + + + + + + + ROIEroded + + + BackgroundImage + + + ROIEroded + + + + + + + + + + 834 + 26 + 682 + 688 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + + + + + + + + + + + + + + + + CroppedBackground + + + CreateArenaFeeds + + + + ArenaROIs + + + + 1 + + + + InputVideoPath + + + + + + + + TrackArenas + + + + + + + + C:\Users\HugoMarques\Documents\Code\MyReps\cf.labs\Marta\3MPTracker\data\RawData\FH3\CR-EmptyTNT-20Control_3BlackOut-Female-4-5days-FH3-CamA-2024-07-19T11_34_57.avi + + + + + 1 + + + + FileName + + + CroppedBackground + + + + + + Source1 + + + + + + + + + CropCenter + + + + Source1 + + + + 1 + + + + This + + + This + + + Item1 + + + + 1 + + + + ThisCropBackground + + + This + + + Item2 + + + Contour + + + Rect + + + X + + + + -1 + + + + Y + + + + -1 + + + + Width + + + + 2 + + + + Height + + + + 2 + + + + + + + ROIEroded + + + Video&Stimuli + + + Video + + + ROIEroded + + + + + + + + + Item1 + + + + + 834 + 26 + 682 + 688 + + + + + ThisCropBackground + + + + + + + + + ThisCropBackground + + + + + + Item2 + + + Stimuli + + + ArenaMask + + + + BackgroundImage + + + This + + + + + + + + + Item1 + + + + + 835 + 27 + 680 + 686 + + + + + This + + + Item2 + + + Contour + + + + 1 + -1 + + + + + + + + ROIEroded + + + + + + + + + + 682 + 688 + + Constant + + 0 + 0 + 0 + 0 + + + 3 + 3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + Item2 + + + + + + new( +Item1 as RawFrame, +Item2 as BackgroundSubtractedFrame, +Item3 as RawBackground, +Item4 as Stimuli, +Item5 as MaskedArena) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ArenaFeeds + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + AnalysisPipeline + + + + ArenaFeeds + + + + 1 + + + + + + + + + + ProcessSingleArenaFrames + + + + Source1 + + + Data + + + + Data + + + Index + + + + 1 + + + + ArenaIndex + + + Data + + + Value + + + + + + ArenaVideoStream + + + CentroidTracking + + + + ArenaVideoStream + + + BackgroundSubtractedFrame + + + + 76 + 255 + Binary + + + + + External + ChainApproxNone + + 0 + 0 + + 3 + + + + + + + + + + + Centroid + + + + 21 + 255 + Binary + + + + + External + ChainApproxNone + + 0 + 0 + + 3 + + + + + + + + + + + Centroid + + + + + + Rename + new( +Item1 as SoftCentroid, +Item2 as HardCentroid) + + + PickBestCentroid + it.SoftCentroid.X > 0 ? it.SoftCentroid : it.HardCentroid + + + BestCentroid + + + BestCentroid + + + ArenaVideoStream + + + RawFrame.RegionOfInterest + + + + + + new( +Item1.X / Item2.Width as X, +Item1.Y / Item2.Height as Y +) + + + + + + + X,Y + + + + 0.6609695 + 0.9361556 + + + + NormalizedBestCentroid + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + PixelChange + + + + ArenaVideoStream + + + BackgroundSubtractedFrame + + + + 1 + 1 + 10 + Binary + Dark + + + + + External + ChainApproxNone + + 0 + 0 + + 3 + + + + + + 1 + -1 + + + + + + + PixelChange + + + + + + + + + + + + + + + + Logging + + + + SaveArena + + + + ArenaVideoStream + + + MaskedArena + + + ThisSessionPaths + + + PostProcessingPath + + + + \Arenas + + + + ThisSessionPaths + + + FileName + + + ArenaIndex + + + + + + {0}/{1}_fly{2}.png + Item1,Item2,Item3 + + + + + + + + + Item1 + + + + C:\Users\HugoMarques\Documents\Code\MyReps\cf.labs\Marta\3MPTracker\data\PostProcessing\Arenas/CR-EmptyTNT-20Control_3BlackOut-Female-4-5days-FH3-CamA-2024-07-19T11_34_57_fly3.png + None + + + + + 1 + + + + + + + + + + + + + + + + + + + + + + + + Track + + + + ThisSessionPaths + + + PostProcessingPath + + + + \Tracked + + + + ThisSessionPaths + + + FileName + + + ArenaIndex + + + + + + {0}/{1}_fly{2}_tracked.csv + Item1,Item2,Item3 + + + + + + + + Video&Stimuli + + + FrameCount_Video + + + ArenaVideoStream + + + Stimuli.Visual,Stimuli.Stim0,Stimuli.Stim1 + + + NormalizedBestCentroid + + + PixelChange + + + + + + Header + new( +Item1 as FrameIndex, +Item2.Item1 as VisualStim, +Item2.Item2 as Stim0, +Item2.Item3 as Stim1, +Item3.X as NormalizedCentroidX, +Item3.Y as NormalizedCentroidY, +Item4 as PixelChange +) + + + C:\Users\HugoMarques\Documents\Code\MyReps\cf.labs\Marta\3MPTracker\data\PostProcessing\Tracked/CR-EmptyTNT-20Control_3BlackOut-Female-4-5days-FH3-CamA-2024-07-19T11_34_57_fly3_tracked.csv + false + false + None + true + + + + + + + + + + + + + + + + + + + + + + + + + + + CropRaw + + + + ThisSessionPaths + + + PostProcessingPath + + + + \CropRaw + + + + ThisSessionPaths + + + FileName + + + ArenaIndex + + + + + + {0}/{1}_fly{2}_crop.avi + Item1,Item2,Item3 + + + + + + + + CenteredVideo + + + + C:\Users\HugoMarques\Documents\Code\MyReps\cf.labs\Marta\3MPTracker\data\PostProcessing\CropRaw/CR-EmptyTNT-20Control_3BlackOut-Female-4-5days-FH3-CamA-2024-07-19T11_34_57_fly3_crop.avi + None + true + false + FMP4 + 60 + + 0 + 0 + + NearestNeighbor + + + + + + + + + + + + + + + + + + + + + CropSubtract + + + + ThisSessionPaths + + + PostProcessingPath + + + + \CropSubtract + + + + ThisSessionPaths + + + FileName + + + ArenaIndex + + + + + + {0}/{1}_fly{2}_cropsub.avi + Item1,Item2,Item3 + + + + + + + + CenteredVideoBackSub + + + + C:\Users\HugoMarques\Documents\Code\MyReps\cf.labs\Marta\3MPTracker\data\PostProcessing\CropSubtract/CR-EmptyTNT-20Control_3BlackOut-Female-4-5days-FH3-CamA-2024-07-19T11_34_57_fly3_cropsub.avi + None + true + false + FMP4 + 60 + + 0 + 0 + + NearestNeighbor + + + + + + + + + + + + + + + + + + + + + Pose + + + + ThisSessionPaths + + + PostProcessingPath + + + + \Pose + + + + ThisSessionPaths + + + FileName + + + ArenaIndex + + + + + + {0}/{1}_fly{2}_pose.csv + Item1,Item2,Item3 + + + + + + + + SleapOutput + + + + Video&Stimuli + + + FrameCount_Video + + + NormalizedBodyParts + + + + + + Header + new( +Item1 as FrameIndex, +Item2.ViewPoints.Left as Left, +Item2.ViewPoints.Right as Right, +Item2.ViewPoints.Top as Top, +Item2.BodyPoints.Head as Head, +Item2.BodyPoints.Thorax as Thorax, +Item2.BodyPoints.Abdomen as Abdomen, +Item2.BodyPoints.LeftWing as LeftWing, +Item2.BodyPoints.RightWing as RightWing +) + + + + + + + + + + + + + + C:\Users\HugoMarques\Documents\Code\MyReps\cf.labs\Marta\3MPTracker\data\PostProcessing\Pose/CR-EmptyTNT-20Control_3BlackOut-Female-4-5days-FH3-CamA-2024-07-19T11_34_57_fly3_pose.csv + false + false + None + true + + + + + + + + + + + + + + + + + + + + SleapModelConfiguration + + + EnableSleap + + + + + + Source1 + + + + false + + + + + + + + + + + + + + + StimVideo + + + + ThisSessionPaths + + + PostProcessingPath + + + + \StimVideos + + + + ThisSessionPaths + + + FileName + + + ArenaIndex + + + + + + {0}/{1}_fly{2}.avi + Item1,Item2,Item3 + + + + + + + + ArenaVideoStream + + + BackgroundSubtractedFrame + + + MaskedArena + + + + + + + + + ArenaVideoStream + + + Stimuli.Visual,Stimuli.Stim0,Stimuli.Stim1 + + + + + + PaintEvent + +import clr +clr.AddReference("OpenCV.Net") +from OpenCV.Net import * +from math import sin, cos, pi + +font = None +def load(): + global font + font = Font(1,1) + +@returns(IplImage) +def process(value): + output = value.Item1.Clone() + image = value.Item1.Clone() + output = IplImage(image.Size, image.Depth, 3) + CV.CvtColor(image,output,ColorConversion.Gray2Bgr) + + visualState = value.Item2.Item1 + stim0State = value.Item2.Item2 + stim1State = value.Item2.Item3 + + if visualState == 1: + CV.Circle(output, Point(25, 25), 15, Scalar.Rgb(255, 255, 255), -1) + else: + CV.Circle(output, Point(25, 25), 15, Scalar.Rgb(32, 32, 32), -1) + + CV.PutText(output,'0',Point(43,24),font,Scalar.All(255)) + CV.PutText(output,'1',Point(43,38),font,Scalar.All(255)) + + if stim0State == 1: + CV.Circle(output, Point(60, 18), 5, Scalar.Rgb(255, 255, 255), -1) + else: + CV.Circle(output, Point(60, 18), 5, Scalar.Rgb(32, 32, 32), -1) + + if stim1State == 1: + CV.Circle(output, Point(60, 33), 5, Scalar.Rgb(255, 255, 255), -1) + else: + CV.Circle(output, Point(60, 33), 5, Scalar.Rgb(32, 32, 32), -1) + + + + return output + + + + + + + + 704 + 704 + + Linear + + + + + C:\Users\HugoMarques\Documents\Code\MyReps\cf.labs\Marta\3MPTracker\data\PostProcessing\StimVideos/CR-EmptyTNT-20Control_3BlackOut-Female-4-5days-FH3-CamA-2024-07-19T11_34_57_fly3.avi + None + true + false + FMP4 + 60 + + 0 + 0 + + NearestNeighbor + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SaveVideo + + + + + + Source1 + + + + true + + + + + + + + + + + + + + + + + + + + + + + + + + + SleapTracking + + + + CenteredVideo + + + SleapModelConfiguration + + + + + + + + + + + + + Extensions\wBackground.frozen_graph.pb + Extensions\wBackground.training_config.json + + + + + + + PoseStream + + + CenteredVideo + + + RegionOfInterest + + + BestCentroid + + + + + + CropCorrection + Returns normalized XY +1.1 Centroid +1.2 pointA +1.3 pointB +2.1 Head +2.2 Thorax +2.3 Abdomen +2.4 Lwing +2.5 Rwing + +import clr +clr.AddReference("OpenCV.Net") +from OpenCV.Net import * +from System import Tuple, Math, Single + +@returns(Point2f) +def process(value): + cropMiddle = Point2f(value.Item1.Width / 2, value.Item1.Height / 2) + + flyCentroid = value.Item2 + + correction = flyCentroid - cropMiddle + + return correction + + + CropCorrection + + + PoseStream + + + NormalizedBodyParts + + + + Source1 + + + ViewPoints + + + + Source1 + + + + Left + + + + Normalizer + + + + Source1 + + + Position,Confidence + + + CropCorrection + + + ArenaVideoStream + + + RawFrame.RegionOfInterest + + + + + + NormalizeXY + Returns normalized XY +1.1 Centroid +1.2 pointA +1.3 pointB +2.1 Head +2.2 Thorax +2.3 Abdomen +2.4 Lwing +2.5 Rwing + +import clr +clr.AddReference("OpenCV.Net") +from OpenCV.Net import * +from System import Tuple, Math, Single + +@returns(Tuple[Point2f,float]) +def process(value): + position = value.Item1.Item1 + confidence = float(value.Item1.Item2) + correction = value.Item2 + arenaWidth = value.Item3.Width + arenaHeight = value.Item3.Height + + corrected = position + correction + + normalized = Point2f(corrected.X / arenaWidth, corrected.Y / arenaHeight) + + output = Tuple.Create(normalized, float(confidence)) + + return output + + + Rename + new( +Item1 as Position, +Item2 as Confidence +) + + + + + + + + + + + + + + + + + + Right + + + + Normalizer + + + + Source1 + + + Position,Confidence + + + CropCorrection + + + ArenaVideoStream + + + RawFrame.RegionOfInterest + + + + + + NormalizeXY + Returns normalized XY +1.1 Centroid +1.2 pointA +1.3 pointB +2.1 Head +2.2 Thorax +2.3 Abdomen +2.4 Lwing +2.5 Rwing + +import clr +clr.AddReference("OpenCV.Net") +from OpenCV.Net import * +from System import Tuple, Math, Single + +@returns(Tuple[Point2f,float]) +def process(value): + position = value.Item1.Item1 + confidence = float(value.Item1.Item2) + correction = value.Item2 + arenaWidth = value.Item3.Width + arenaHeight = value.Item3.Height + + corrected = position + correction + + normalized = Point2f(corrected.X / arenaWidth, corrected.Y / arenaHeight) + + output = Tuple.Create(normalized, float(confidence)) + + return output + + + Rename + new( +Item1 as Position, +Item2 as Confidence +) + + + + + + + + + + + + + + + + + + Top + + + + Normalizer + + + + Source1 + + + Position,Confidence + + + CropCorrection + + + ArenaVideoStream + + + RawFrame.RegionOfInterest + + + + + + NormalizeXY + Returns normalized XY +1.1 Centroid +1.2 pointA +1.3 pointB +2.1 Head +2.2 Thorax +2.3 Abdomen +2.4 Lwing +2.5 Rwing + +import clr +clr.AddReference("OpenCV.Net") +from OpenCV.Net import * +from System import Tuple, Math, Single + +@returns(Tuple[Point2f,float]) +def process(value): + position = value.Item1.Item1 + confidence = float(value.Item1.Item2) + correction = value.Item2 + arenaWidth = value.Item3.Width + arenaHeight = value.Item3.Height + + corrected = position + correction + + normalized = Point2f(corrected.X / arenaWidth, corrected.Y / arenaHeight) + + output = Tuple.Create(normalized, float(confidence)) + + return output + + + Rename + new( +Item1 as Position, +Item2 as Confidence +) + + + + + + + + + + + + + + + + + + + + Rename + new( +Item1 as Left, +Item2 as Right, +Item3 as Top) + + + + + + + + + + + + + + + + + + + + BodyPoints + + + + Source1 + + + + Head + + + + Normalizer + + + + Source1 + + + Position,Confidence + + + CropCorrection + + + ArenaVideoStream + + + RawFrame.RegionOfInterest + + + + + + NormalizeXY + Returns normalized XY +1.1 Centroid +1.2 pointA +1.3 pointB +2.1 Head +2.2 Thorax +2.3 Abdomen +2.4 Lwing +2.5 Rwing + +import clr +clr.AddReference("OpenCV.Net") +from OpenCV.Net import * +from System import Tuple, Math, Single + +@returns(Tuple[Point2f,float]) +def process(value): + position = value.Item1.Item1 + confidence = float(value.Item1.Item2) + correction = value.Item2 + arenaWidth = value.Item3.Width + arenaHeight = value.Item3.Height + + corrected = position + correction + + normalized = Point2f(corrected.X / arenaWidth, corrected.Y / arenaHeight) + + output = Tuple.Create(normalized, float(confidence)) + + return output + + + Rename + new( +Item1 as Position, +Item2 as Confidence +) + + + + + + + + + + + + + + + + + + Thorax + + + + Normalizer + + + + Source1 + + + Position,Confidence + + + CropCorrection + + + ArenaVideoStream + + + RawFrame.RegionOfInterest + + + + + + NormalizeXY + Returns normalized XY +1.1 Centroid +1.2 pointA +1.3 pointB +2.1 Head +2.2 Thorax +2.3 Abdomen +2.4 Lwing +2.5 Rwing + +import clr +clr.AddReference("OpenCV.Net") +from OpenCV.Net import * +from System import Tuple, Math, Single + +@returns(Tuple[Point2f,float]) +def process(value): + position = value.Item1.Item1 + confidence = float(value.Item1.Item2) + correction = value.Item2 + arenaWidth = value.Item3.Width + arenaHeight = value.Item3.Height + + corrected = position + correction + + normalized = Point2f(corrected.X / arenaWidth, corrected.Y / arenaHeight) + + output = Tuple.Create(normalized, float(confidence)) + + return output + + + Rename + new( +Item1 as Position, +Item2 as Confidence +) + + + + + + + + + + + + + + + + + + Abdomen + + + + Normalizer + + + + Source1 + + + Position,Confidence + + + CropCorrection + + + ArenaVideoStream + + + RawFrame.RegionOfInterest + + + + + + NormalizeXY + Returns normalized XY +1.1 Centroid +1.2 pointA +1.3 pointB +2.1 Head +2.2 Thorax +2.3 Abdomen +2.4 Lwing +2.5 Rwing + +import clr +clr.AddReference("OpenCV.Net") +from OpenCV.Net import * +from System import Tuple, Math, Single + +@returns(Tuple[Point2f,float]) +def process(value): + position = value.Item1.Item1 + confidence = float(value.Item1.Item2) + correction = value.Item2 + arenaWidth = value.Item3.Width + arenaHeight = value.Item3.Height + + corrected = position + correction + + normalized = Point2f(corrected.X / arenaWidth, corrected.Y / arenaHeight) + + output = Tuple.Create(normalized, float(confidence)) + + return output + + + Rename + new( +Item1 as Position, +Item2 as Confidence +) + + + + + + + + + + + + + + + + + + LeftWing + + + + Normalizer + + + + Source1 + + + Position,Confidence + + + CropCorrection + + + ArenaVideoStream + + + RawFrame.RegionOfInterest + + + + + + NormalizeXY + Returns normalized XY +1.1 Centroid +1.2 pointA +1.3 pointB +2.1 Head +2.2 Thorax +2.3 Abdomen +2.4 Lwing +2.5 Rwing + +import clr +clr.AddReference("OpenCV.Net") +from OpenCV.Net import * +from System import Tuple, Math, Single + +@returns(Tuple[Point2f,float]) +def process(value): + position = value.Item1.Item1 + confidence = float(value.Item1.Item2) + correction = value.Item2 + arenaWidth = value.Item3.Width + arenaHeight = value.Item3.Height + + corrected = position + correction + + normalized = Point2f(corrected.X / arenaWidth, corrected.Y / arenaHeight) + + output = Tuple.Create(normalized, float(confidence)) + + return output + + + Rename + new( +Item1 as Position, +Item2 as Confidence +) + + + + + + + + + + + + + + + + + + RightWing + + + + Normalizer + + + + Source1 + + + Position,Confidence + + + CropCorrection + + + ArenaVideoStream + + + RawFrame.RegionOfInterest + + + + + + NormalizeXY + Returns normalized XY +1.1 Centroid +1.2 pointA +1.3 pointB +2.1 Head +2.2 Thorax +2.3 Abdomen +2.4 Lwing +2.5 Rwing + +import clr +clr.AddReference("OpenCV.Net") +from OpenCV.Net import * +from System import Tuple, Math, Single + +@returns(Tuple[Point2f,float]) +def process(value): + position = value.Item1.Item1 + confidence = float(value.Item1.Item2) + correction = value.Item2 + arenaWidth = value.Item3.Width + arenaHeight = value.Item3.Height + + corrected = position + correction + + normalized = Point2f(corrected.X / arenaWidth, corrected.Y / arenaHeight) + + output = Tuple.Create(normalized, float(confidence)) + + return output + + + Rename + new( +Item1 as Position, +Item2 as Confidence +) + + + + + + + + + + + + + + + + + + + + Rename + new( +Item1 as Head, +Item2 as Thorax, +Item3 as Abdomen, +Item4 as LeftWing, +Item5 as RightWing +) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Rename + new( +Item1 as ViewPoints, +Item2 as BodyPoints) + + + + + + + + + + + + + + + NormalizedBodyParts + + + + + + + + + + + + + + + + + + + + + SleapModelConfiguration + + + EnableSleap + + + + + + Source1 + + + + + + + + + + + + + VisualizerOut + + + + CenteredVideo + + + + ArenaVideoStream + + + RawFrame + + + BestCentroid + + + + + + FlyCenteredCropSize + + + + + + + + + + 128 + 128 + + + 0 + 0 + 0 + 0 + + + + + CenteredVideo + + + + ArenaVideoStream + + + BackgroundSubtractedFrame + + + BestCentroid + + + + + + FlyCenteredCropSize + + + + + + + + + + 128 + 128 + + + 0 + 0 + 0 + 0 + + + + + CenteredVideoBackSub + + + + + + + + + + + + + + + + + + + + + + + Video&Stimuli + + + FrameCount_Video + + + Header + new(it as FrameCount_ArenaStream) + + + Stimuli + + + + + + ArenaIndex + + + + + + ThisSessionPaths + + + FileName + + + + + + Item1.Item2 + + + Item1.Item1.Item1 + + + Item1.Item1.Item2 + + + Item1.Item1.Item3 + + + Item2 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Visualizers + + + + Source1 + + + + + + Source1 + + + Item1 + + + + + + + 0 + + + + + + + + + + + + + + Item2 + + + + + + + + + Source1 + + + Item1 + + + + + + + 1 + + + + + + + + + + + + + + Item2 + + + + + + Item4.Visual,Item4.Stim0,Item4.Stim1 + + + + + 128 + 128 + + U8 + 3 + + 0 + 0 + 0 + 0 + + + + + + + + + + + + + + PaintLED + +import clr +clr.AddReference("OpenCV.Net") +from OpenCV.Net import * +from math import sin, cos, pi + +font = None +def load(): + global font + font = Font(2,2) + +@returns(IplImage) +def process(value): + output = value.Item2.Clone() + image = value.Item2.Clone() + output = IplImage(image.Size, image.Depth, 3) + CV.CvtColor(image,output,ColorConversion.Gray2Bgr) + + LoomState = value.Item1.Item1 + RedState = value.Item1.Item2 + GreenState = value.Item1.Item3 + + if RedState == 1: + CV.Circle(output, Point(64, 64), 55, Scalar.Rgb(204, 0, 0), -1) + + if GreenState == 1: + CV.Circle(output, Point(64, 64), 55, Scalar.Rgb(0, 204, 0), -1) + + if LoomState == 1: + CV.Circle(output, Point(64, 64), 40, Scalar.Rgb(255, 255, 255), -1) + else: + CV.Circle(output, Point(64, 64), 40, Scalar.Rgb(32, 32, 32), -1) + + return output + + + + + + + + + Source1 + + + Item1 + + + + + + + 2 + + + + + + + + + + + + + + Item2 + + + + + + + + + Source1 + + + Item1 + + + + + + + 3 + + + + + + + + + + + + + + Item2 + + + + + + Item2 + + + Item5 + + + + + + + + + Index + + + + 1 + + + + + + + Item1 + + + Item2 + + + Item3.FrameCount_ArenaStream + + + + + + TimeInfo + +import clr +clr.AddReference("OpenCV.Net") +from OpenCV.Net import * +from math import sin, cos, pi + +font = None +def load(): + global font + font = Font(1,1) + +@returns(IplImage) +def process(value): + output = value.Item1.Clone() + image = value.Item1.Clone() + output = IplImage(image.Size, image.Depth, 3) + CV.CvtColor(image,output,ColorConversion.Gray2Bgr) + + filenumber = 'File # ' + value.Item2.ToString() + CV.PutText(output,filenumber,Point(5,45),font,Scalar.All(255)) + + FrameNumber = '# ' + value.Item3.ToString() + CV.PutText(output,'Frame',Point(5,80),font,Scalar.All(255)) + CV.PutText(output,FrameNumber,Point(5,100),font,Scalar.All(255)) + + return output + + + + + + 3 + 2 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + FileFinished + + + + 1 + + + + + + + Source1 + + + + + + Index + + + NumberOfFiles + + + + 1 + + + + + + + + + + + + + + + + + + + + + + 1 + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Marta/3MPTracker/src/Extensions.csproj b/Marta/3MPTracker/src/Extensions.csproj new file mode 100644 index 0000000..f6fb523 --- /dev/null +++ b/Marta/3MPTracker/src/Extensions.csproj @@ -0,0 +1,14 @@ + + + + net472 + + + + + + + + + + \ No newline at end of file diff --git a/Marta/3MPTracker/src/Extensions/AutomaticGenerators.Generated.cs b/Marta/3MPTracker/src/Extensions/AutomaticGenerators.Generated.cs new file mode 100644 index 0000000..e3b810e --- /dev/null +++ b/Marta/3MPTracker/src/Extensions/AutomaticGenerators.Generated.cs @@ -0,0 +1,1148 @@ +//---------------------- +// +// Generated using the NJsonSchema v10.9.0.0 (Newtonsoft.Json v9.0.0.0) (http://NJsonSchema.org) +// +//---------------------- + + +namespace AutomaticGenerators +{ + #pragma warning disable // Disable all warnings + + [Bonsai.CombinatorAttribute()] + [Bonsai.WorkflowElementCategoryAttribute(Bonsai.ElementCategory.Source)] + public partial class Point + { + + private double _x = 0D; + + private double _y = 0D; + + [YamlDotNet.Serialization.YamlMemberAttribute(Alias="x")] + public double X + { + get + { + return _x; + } + set + { + _x = value; + } + } + + [YamlDotNet.Serialization.YamlMemberAttribute(Alias="y")] + public double Y + { + get + { + return _y; + } + set + { + _y = value; + } + } + + public System.IObservable Process() + { + return System.Reactive.Linq.Observable.Defer(() => System.Reactive.Linq.Observable.Return( + new Point + { + X = _x, + Y = _y + })); + } + } + + + [Bonsai.CombinatorAttribute()] + [Bonsai.WorkflowElementCategoryAttribute(Bonsai.ElementCategory.Source)] + public partial class AnimationSettings + { + + private double _duration = 2D; + + private double _initialRadius = 0.5D; + + private double _initialVirtualDistance = 12.5D; + + private double _linearApproachingVelocity = 25D; + + private double _maxRadius = 25D; + + private double _monitorDistance = 25D; + + [YamlDotNet.Serialization.YamlMemberAttribute(Alias="duration")] + public double Duration + { + get + { + return _duration; + } + set + { + _duration = value; + } + } + + [YamlDotNet.Serialization.YamlMemberAttribute(Alias="initialRadius")] + public double InitialRadius + { + get + { + return _initialRadius; + } + set + { + _initialRadius = value; + } + } + + [YamlDotNet.Serialization.YamlMemberAttribute(Alias="initialVirtualDistance")] + public double InitialVirtualDistance + { + get + { + return _initialVirtualDistance; + } + set + { + _initialVirtualDistance = value; + } + } + + [YamlDotNet.Serialization.YamlMemberAttribute(Alias="linearApproachingVelocity")] + public double LinearApproachingVelocity + { + get + { + return _linearApproachingVelocity; + } + set + { + _linearApproachingVelocity = value; + } + } + + [YamlDotNet.Serialization.YamlMemberAttribute(Alias="maxRadius")] + public double MaxRadius + { + get + { + return _maxRadius; + } + set + { + _maxRadius = value; + } + } + + [YamlDotNet.Serialization.YamlMemberAttribute(Alias="monitorDistance")] + public double MonitorDistance + { + get + { + return _monitorDistance; + } + set + { + _monitorDistance = value; + } + } + + public System.IObservable Process() + { + return System.Reactive.Linq.Observable.Defer(() => System.Reactive.Linq.Observable.Return( + new AnimationSettings + { + Duration = _duration, + InitialRadius = _initialRadius, + InitialVirtualDistance = _initialVirtualDistance, + LinearApproachingVelocity = _linearApproachingVelocity, + MaxRadius = _maxRadius, + MonitorDistance = _monitorDistance + })); + } + } + + + [Bonsai.CombinatorAttribute()] + [Bonsai.WorkflowElementCategoryAttribute(Bonsai.ElementCategory.Source)] + public partial class Color + { + + private double _a = 1D; + + private double _b = 0D; + + private double _g = 0D; + + private double _r = 0D; + + [YamlDotNet.Serialization.YamlMemberAttribute(Alias="a")] + public double A + { + get + { + return _a; + } + set + { + _a = value; + } + } + + [YamlDotNet.Serialization.YamlMemberAttribute(Alias="b")] + public double B + { + get + { + return _b; + } + set + { + _b = value; + } + } + + [YamlDotNet.Serialization.YamlMemberAttribute(Alias="g")] + public double G + { + get + { + return _g; + } + set + { + _g = value; + } + } + + [YamlDotNet.Serialization.YamlMemberAttribute(Alias="r")] + public double R + { + get + { + return _r; + } + set + { + _r = value; + } + } + + public System.IObservable Process() + { + return System.Reactive.Linq.Observable.Defer(() => System.Reactive.Linq.Observable.Return( + new Color + { + A = _a, + B = _b, + G = _g, + R = _r + })); + } + } + + + [Bonsai.CombinatorAttribute()] + [Bonsai.WorkflowElementCategoryAttribute(Bonsai.ElementCategory.Source)] + public partial class ControlNoisyStimuli + { + + private AnimationSettings _animationSettings; + + private Color _backgroundColor; + + private double _delayOffset; + + private double _delayOnset; + + private double _diameter = 0.1D; + + private Color _offColor; + + private Color _onColor; + + [System.Xml.Serialization.XmlIgnoreAttribute()] + [YamlDotNet.Serialization.YamlMemberAttribute(Alias="animationSettings")] + public AnimationSettings AnimationSettings + { + get + { + return _animationSettings; + } + set + { + _animationSettings = value; + } + } + + [System.Xml.Serialization.XmlIgnoreAttribute()] + [YamlDotNet.Serialization.YamlMemberAttribute(Alias="backgroundColor")] + public Color BackgroundColor + { + get + { + return _backgroundColor; + } + set + { + _backgroundColor = value; + } + } + + [YamlDotNet.Serialization.YamlMemberAttribute(Alias="delayOffset")] + public double DelayOffset + { + get + { + return _delayOffset; + } + set + { + _delayOffset = value; + } + } + + [YamlDotNet.Serialization.YamlMemberAttribute(Alias="delayOnset")] + public double DelayOnset + { + get + { + return _delayOnset; + } + set + { + _delayOnset = value; + } + } + + [YamlDotNet.Serialization.YamlMemberAttribute(Alias="diameter")] + public double Diameter + { + get + { + return _diameter; + } + set + { + _diameter = value; + } + } + + [System.Xml.Serialization.XmlIgnoreAttribute()] + [YamlDotNet.Serialization.YamlMemberAttribute(Alias="offColor")] + public Color OffColor + { + get + { + return _offColor; + } + set + { + _offColor = value; + } + } + + [System.Xml.Serialization.XmlIgnoreAttribute()] + [YamlDotNet.Serialization.YamlMemberAttribute(Alias="onColor")] + public Color OnColor + { + get + { + return _onColor; + } + set + { + _onColor = value; + } + } + + public System.IObservable Process() + { + return System.Reactive.Linq.Observable.Defer(() => System.Reactive.Linq.Observable.Return( + new ControlNoisyStimuli + { + AnimationSettings = _animationSettings, + BackgroundColor = _backgroundColor, + DelayOffset = _delayOffset, + DelayOnset = _delayOnset, + Diameter = _diameter, + OffColor = _offColor, + OnColor = _onColor + })); + } + } + + + [Bonsai.CombinatorAttribute()] + [Bonsai.WorkflowElementCategoryAttribute(Bonsai.ElementCategory.Source)] + public partial class LoomingCircleStimuli + { + + private AnimationSettings _animationSettings; + + private Color _backgroundColor; + + private Color _color; + + private double _delayOffset; + + private double _delayOnset; + + [System.Xml.Serialization.XmlIgnoreAttribute()] + [YamlDotNet.Serialization.YamlMemberAttribute(Alias="animationSettings")] + public AnimationSettings AnimationSettings + { + get + { + return _animationSettings; + } + set + { + _animationSettings = value; + } + } + + [System.Xml.Serialization.XmlIgnoreAttribute()] + [YamlDotNet.Serialization.YamlMemberAttribute(Alias="backgroundColor")] + public Color BackgroundColor + { + get + { + return _backgroundColor; + } + set + { + _backgroundColor = value; + } + } + + [System.Xml.Serialization.XmlIgnoreAttribute()] + [YamlDotNet.Serialization.YamlMemberAttribute(Alias="color")] + public Color Color + { + get + { + return _color; + } + set + { + _color = value; + } + } + + [YamlDotNet.Serialization.YamlMemberAttribute(Alias="delayOffset")] + public double DelayOffset + { + get + { + return _delayOffset; + } + set + { + _delayOffset = value; + } + } + + [YamlDotNet.Serialization.YamlMemberAttribute(Alias="delayOnset")] + public double DelayOnset + { + get + { + return _delayOnset; + } + set + { + _delayOnset = value; + } + } + + public System.IObservable Process() + { + return System.Reactive.Linq.Observable.Defer(() => System.Reactive.Linq.Observable.Return( + new LoomingCircleStimuli + { + AnimationSettings = _animationSettings, + BackgroundColor = _backgroundColor, + Color = _color, + DelayOffset = _delayOffset, + DelayOnset = _delayOnset + })); + } + } + + + [Bonsai.CombinatorAttribute()] + [Bonsai.WorkflowElementCategoryAttribute(Bonsai.ElementCategory.Source)] + public partial class LoomingImageStimuli + { + + private AnimationSettings _animationSettings; + + private Color _backgroundColor; + + private double _delayOffset; + + private double _delayOnset; + + private double _scaleX = 1D; + + private double _scaleY = 1D; + + private string _textureName = ""; + + [System.Xml.Serialization.XmlIgnoreAttribute()] + [YamlDotNet.Serialization.YamlMemberAttribute(Alias="animationSettings")] + public AnimationSettings AnimationSettings + { + get + { + return _animationSettings; + } + set + { + _animationSettings = value; + } + } + + [System.Xml.Serialization.XmlIgnoreAttribute()] + [YamlDotNet.Serialization.YamlMemberAttribute(Alias="backgroundColor")] + public Color BackgroundColor + { + get + { + return _backgroundColor; + } + set + { + _backgroundColor = value; + } + } + + [YamlDotNet.Serialization.YamlMemberAttribute(Alias="delayOffset")] + public double DelayOffset + { + get + { + return _delayOffset; + } + set + { + _delayOffset = value; + } + } + + [YamlDotNet.Serialization.YamlMemberAttribute(Alias="delayOnset")] + public double DelayOnset + { + get + { + return _delayOnset; + } + set + { + _delayOnset = value; + } + } + + [YamlDotNet.Serialization.YamlMemberAttribute(Alias="scaleX")] + public double ScaleX + { + get + { + return _scaleX; + } + set + { + _scaleX = value; + } + } + + [YamlDotNet.Serialization.YamlMemberAttribute(Alias="scaleY")] + public double ScaleY + { + get + { + return _scaleY; + } + set + { + _scaleY = value; + } + } + + [YamlDotNet.Serialization.YamlMemberAttribute(Alias="textureName")] + public string TextureName + { + get + { + return _textureName; + } + set + { + _textureName = value; + } + } + + public System.IObservable Process() + { + return System.Reactive.Linq.Observable.Defer(() => System.Reactive.Linq.Observable.Return( + new LoomingImageStimuli + { + AnimationSettings = _animationSettings, + BackgroundColor = _backgroundColor, + DelayOffset = _delayOffset, + DelayOnset = _delayOnset, + ScaleX = _scaleX, + ScaleY = _scaleY, + TextureName = _textureName + })); + } + } + + + [Bonsai.CombinatorAttribute()] + [Bonsai.WorkflowElementCategoryAttribute(Bonsai.ElementCategory.Source)] + public partial class MovingCircleStimuli + { + + private Point _startPosition; + + private Point _endPosition; + + private Color _backgroundColor; + + private Color _color; + + private double _delayOffset; + + private double _delayOnset; + + private double _radius = 1D; + + private double _duration = 1D; + + [System.Xml.Serialization.XmlIgnoreAttribute()] + [YamlDotNet.Serialization.YamlMemberAttribute(Alias="startPosition")] + public Point StartPosition + { + get + { + return _startPosition; + } + set + { + _startPosition = value; + } + } + + [System.Xml.Serialization.XmlIgnoreAttribute()] + [YamlDotNet.Serialization.YamlMemberAttribute(Alias="endPosition")] + public Point EndPosition + { + get + { + return _endPosition; + } + set + { + _endPosition = value; + } + } + + [System.Xml.Serialization.XmlIgnoreAttribute()] + [YamlDotNet.Serialization.YamlMemberAttribute(Alias="backgroundColor")] + public Color BackgroundColor + { + get + { + return _backgroundColor; + } + set + { + _backgroundColor = value; + } + } + + [System.Xml.Serialization.XmlIgnoreAttribute()] + [YamlDotNet.Serialization.YamlMemberAttribute(Alias="color")] + public Color Color + { + get + { + return _color; + } + set + { + _color = value; + } + } + + [YamlDotNet.Serialization.YamlMemberAttribute(Alias="delayOffset")] + public double DelayOffset + { + get + { + return _delayOffset; + } + set + { + _delayOffset = value; + } + } + + [YamlDotNet.Serialization.YamlMemberAttribute(Alias="delayOnset")] + public double DelayOnset + { + get + { + return _delayOnset; + } + set + { + _delayOnset = value; + } + } + + [YamlDotNet.Serialization.YamlMemberAttribute(Alias="radius")] + public double Radius + { + get + { + return _radius; + } + set + { + _radius = value; + } + } + + [YamlDotNet.Serialization.YamlMemberAttribute(Alias="duration")] + public double Duration + { + get + { + return _duration; + } + set + { + _duration = value; + } + } + + public System.IObservable Process() + { + return System.Reactive.Linq.Observable.Defer(() => System.Reactive.Linq.Observable.Return( + new MovingCircleStimuli + { + StartPosition = _startPosition, + EndPosition = _endPosition, + BackgroundColor = _backgroundColor, + Color = _color, + DelayOffset = _delayOffset, + DelayOnset = _delayOnset, + Radius = _radius, + Duration = _duration + })); + } + } + + + [Bonsai.CombinatorAttribute()] + [Bonsai.WorkflowElementCategoryAttribute(Bonsai.ElementCategory.Source)] + public partial class OptogeneticsStimuli + { + + private double _amplitude = 1D; + + private double _duration = 1D; + + private int _dutyCycle = 50; + + private double _frequency = 10D; + + private OptogeneticsStimuliLedTarget _ledTarget = AutomaticGenerators.OptogeneticsStimuliLedTarget.None; + + private OptogeneticsStimuliMode _mode = AutomaticGenerators.OptogeneticsStimuliMode.Continuous; + + [YamlDotNet.Serialization.YamlMemberAttribute(Alias="amplitude")] + public double Amplitude + { + get + { + return _amplitude; + } + set + { + _amplitude = value; + } + } + + [YamlDotNet.Serialization.YamlMemberAttribute(Alias="duration")] + public double Duration + { + get + { + return _duration; + } + set + { + _duration = value; + } + } + + [YamlDotNet.Serialization.YamlMemberAttribute(Alias="dutyCycle")] + public int DutyCycle + { + get + { + return _dutyCycle; + } + set + { + _dutyCycle = value; + } + } + + [YamlDotNet.Serialization.YamlMemberAttribute(Alias="frequency")] + public double Frequency + { + get + { + return _frequency; + } + set + { + _frequency = value; + } + } + + [System.Xml.Serialization.XmlIgnoreAttribute()] + [YamlDotNet.Serialization.YamlMemberAttribute(Alias="ledTarget")] + public OptogeneticsStimuliLedTarget LedTarget + { + get + { + return _ledTarget; + } + set + { + _ledTarget = value; + } + } + + [System.Xml.Serialization.XmlIgnoreAttribute()] + [YamlDotNet.Serialization.YamlMemberAttribute(Alias="mode")] + public OptogeneticsStimuliMode Mode + { + get + { + return _mode; + } + set + { + _mode = value; + } + } + + public System.IObservable Process() + { + return System.Reactive.Linq.Observable.Defer(() => System.Reactive.Linq.Observable.Return( + new OptogeneticsStimuli + { + Amplitude = _amplitude, + Duration = _duration, + DutyCycle = _dutyCycle, + Frequency = _frequency, + LedTarget = _ledTarget, + Mode = _mode + })); + } + } + + + [Bonsai.CombinatorAttribute()] + [Bonsai.WorkflowElementCategoryAttribute(Bonsai.ElementCategory.Source)] + public partial class TrialSettings + { + + private ControlNoisyStimuli _controlNoisyStimuli; + + private LoomingCircleStimuli _loomingCircleStimuli; + + private LoomingImageStimuli _loomingImageStimuli; + + private OptogeneticsStimuli _optogeneticsStimuli; + + private MovingCircleStimuli _movingCircleStimuli; + + [System.Xml.Serialization.XmlIgnoreAttribute()] + [YamlDotNet.Serialization.YamlMemberAttribute(Alias="controlNoisyStimuli")] + public ControlNoisyStimuli ControlNoisyStimuli + { + get + { + return _controlNoisyStimuli; + } + set + { + _controlNoisyStimuli = value; + } + } + + [System.Xml.Serialization.XmlIgnoreAttribute()] + [YamlDotNet.Serialization.YamlMemberAttribute(Alias="loomingCircleStimuli")] + public LoomingCircleStimuli LoomingCircleStimuli + { + get + { + return _loomingCircleStimuli; + } + set + { + _loomingCircleStimuli = value; + } + } + + [System.Xml.Serialization.XmlIgnoreAttribute()] + [YamlDotNet.Serialization.YamlMemberAttribute(Alias="loomingImageStimuli")] + public LoomingImageStimuli LoomingImageStimuli + { + get + { + return _loomingImageStimuli; + } + set + { + _loomingImageStimuli = value; + } + } + + [System.Xml.Serialization.XmlIgnoreAttribute()] + [YamlDotNet.Serialization.YamlMemberAttribute(Alias="optogeneticsStimuli")] + public OptogeneticsStimuli OptogeneticsStimuli + { + get + { + return _optogeneticsStimuli; + } + set + { + _optogeneticsStimuli = value; + } + } + + [System.Xml.Serialization.XmlIgnoreAttribute()] + [YamlDotNet.Serialization.YamlMemberAttribute(Alias="movingCircleStimuli")] + public MovingCircleStimuli MovingCircleStimuli + { + get + { + return _movingCircleStimuli; + } + set + { + _movingCircleStimuli = value; + } + } + + public System.IObservable Process() + { + return System.Reactive.Linq.Observable.Defer(() => System.Reactive.Linq.Observable.Return( + new TrialSettings + { + ControlNoisyStimuli = _controlNoisyStimuli, + LoomingCircleStimuli = _loomingCircleStimuli, + LoomingImageStimuli = _loomingImageStimuli, + OptogeneticsStimuli = _optogeneticsStimuli, + MovingCircleStimuli = _movingCircleStimuli + })); + } + } + + + [Bonsai.CombinatorAttribute()] + [Bonsai.WorkflowElementCategoryAttribute(Bonsai.ElementCategory.Source)] + public partial class BonFlyStimuli + { + + private System.Collections.Generic.List _trials = new System.Collections.Generic.List(); + + [System.Xml.Serialization.XmlIgnoreAttribute()] + [YamlDotNet.Serialization.YamlMemberAttribute(Alias="trials")] + public System.Collections.Generic.List Trials + { + get + { + return _trials; + } + set + { + _trials = value; + } + } + + public System.IObservable Process() + { + return System.Reactive.Linq.Observable.Defer(() => System.Reactive.Linq.Observable.Return( + new BonFlyStimuli + { + Trials = _trials + })); + } + } + + + public enum OptogeneticsStimuliLedTarget + { + + [YamlDotNet.Serialization.YamlMemberAttribute(Alias="None")] + None = 0, + + [YamlDotNet.Serialization.YamlMemberAttribute(Alias="Led0")] + Led0 = 1, + + [YamlDotNet.Serialization.YamlMemberAttribute(Alias="Led1")] + Led1 = 2, + + [YamlDotNet.Serialization.YamlMemberAttribute(Alias="Both")] + Both = 3, + } + + + public enum OptogeneticsStimuliMode + { + + [YamlDotNet.Serialization.YamlMemberAttribute(Alias="Continuous")] + Continuous = 0, + + [YamlDotNet.Serialization.YamlMemberAttribute(Alias="Pulsed")] + Pulsed = 1, + } + + + /// + /// Serializes a sequence of data model objects into YAML strings. + /// + [Bonsai.CombinatorAttribute()] + [Bonsai.WorkflowElementCategoryAttribute(Bonsai.ElementCategory.Transform)] + [System.ComponentModel.DescriptionAttribute("Serializes a sequence of data model objects into YAML strings.")] + public partial class SerializeToYaml + { + + private System.IObservable Process(System.IObservable source) + { + return System.Reactive.Linq.Observable.Defer(() => + { + var serializer = new YamlDotNet.Serialization.SerializerBuilder().Build(); + return System.Reactive.Linq.Observable.Select(source, value => serializer.Serialize(value)); + }); + } + + public System.IObservable Process(System.IObservable source) + { + return Process(source); + } + + public System.IObservable Process(System.IObservable source) + { + return Process(source); + } + + public System.IObservable Process(System.IObservable source) + { + return Process(source); + } + + public System.IObservable Process(System.IObservable source) + { + return Process(source); + } + + public System.IObservable Process(System.IObservable source) + { + return Process(source); + } + + public System.IObservable Process(System.IObservable source) + { + return Process(source); + } + + public System.IObservable Process(System.IObservable source) + { + return Process(source); + } + + public System.IObservable Process(System.IObservable source) + { + return Process(source); + } + + public System.IObservable Process(System.IObservable source) + { + return Process(source); + } + + public System.IObservable Process(System.IObservable source) + { + return Process(source); + } + } + + + /// + /// Deserializes a sequence of YAML strings into data model objects. + /// + [System.ComponentModel.DefaultPropertyAttribute("Type")] + [Bonsai.WorkflowElementCategoryAttribute(Bonsai.ElementCategory.Transform)] + [System.Xml.Serialization.XmlIncludeAttribute(typeof(Bonsai.Expressions.TypeMapping))] + [System.Xml.Serialization.XmlIncludeAttribute(typeof(Bonsai.Expressions.TypeMapping))] + [System.Xml.Serialization.XmlIncludeAttribute(typeof(Bonsai.Expressions.TypeMapping))] + [System.Xml.Serialization.XmlIncludeAttribute(typeof(Bonsai.Expressions.TypeMapping))] + [System.Xml.Serialization.XmlIncludeAttribute(typeof(Bonsai.Expressions.TypeMapping))] + [System.Xml.Serialization.XmlIncludeAttribute(typeof(Bonsai.Expressions.TypeMapping))] + [System.Xml.Serialization.XmlIncludeAttribute(typeof(Bonsai.Expressions.TypeMapping))] + [System.Xml.Serialization.XmlIncludeAttribute(typeof(Bonsai.Expressions.TypeMapping))] + [System.Xml.Serialization.XmlIncludeAttribute(typeof(Bonsai.Expressions.TypeMapping))] + [System.Xml.Serialization.XmlIncludeAttribute(typeof(Bonsai.Expressions.TypeMapping))] + [System.ComponentModel.DescriptionAttribute("Deserializes a sequence of YAML strings into data model objects.")] + public partial class DeserializeFromYaml : Bonsai.Expressions.SingleArgumentExpressionBuilder + { + + public DeserializeFromYaml() + { + Type = new Bonsai.Expressions.TypeMapping(); + } + + public Bonsai.Expressions.TypeMapping Type { get; set; } + + public override System.Linq.Expressions.Expression Build(System.Collections.Generic.IEnumerable arguments) + { + var typeMapping = (Bonsai.Expressions.TypeMapping)Type; + var returnType = typeMapping.GetType().GetGenericArguments()[0]; + return System.Linq.Expressions.Expression.Call( + typeof(DeserializeFromYaml), + "Process", + new System.Type[] { returnType }, + System.Linq.Enumerable.Single(arguments)); + } + + private static System.IObservable Process(System.IObservable source) + { + return System.Reactive.Linq.Observable.Defer(() => + { + var serializer = new YamlDotNet.Serialization.DeserializerBuilder().Build(); + return System.Reactive.Linq.Observable.Select(source, value => + { + var reader = new System.IO.StringReader(value); + var parser = new YamlDotNet.Core.MergingParser(new YamlDotNet.Core.Parser(reader)); + return serializer.Deserialize(parser); + }); + }); + } + } +} \ No newline at end of file diff --git a/Marta/3MPTracker/src/Extensions/BonFlyResources.bonsai b/Marta/3MPTracker/src/Extensions/BonFlyResources.bonsai new file mode 100644 index 0000000..812d300 --- /dev/null +++ b/Marta/3MPTracker/src/Extensions/BonFlyResources.bonsai @@ -0,0 +1,34 @@ + + + + + + Source1 + + + + + + RandomNoiseCircle + + + + + BonVision:Shaders.Quad.vert + Shaders\RandomNoiseContrast.frag + + + + + + + + + + + + \ No newline at end of file diff --git a/Marta/3MPTracker/src/Extensions/BonFlyView.bonsai b/Marta/3MPTracker/src/Extensions/BonFlyView.bonsai new file mode 100644 index 0000000..b367b60 --- /dev/null +++ b/Marta/3MPTracker/src/Extensions/BonFlyView.bonsai @@ -0,0 +1,30 @@ + + + + + + Source1 + + + + + + + + + -27.185 + 27.185 + -15.13 + 15.13 + + + + + + + + + + \ No newline at end of file diff --git a/Marta/3MPTracker/src/Extensions/CalculateLoomRadius.cs b/Marta/3MPTracker/src/Extensions/CalculateLoomRadius.cs new file mode 100644 index 0000000..8a90d82 --- /dev/null +++ b/Marta/3MPTracker/src/Extensions/CalculateLoomRadius.cs @@ -0,0 +1,67 @@ +using Bonsai; +using System; +using System.ComponentModel; +using System.Collections.Generic; +using System.Linq; +using System.Reactive.Linq; + +[Combinator] +[Description("Generates a virtual loom radius based on the linear approaching velocity of the virtual looming object. See Ache et al. 2019 for details")] +[WorkflowElementCategory(ElementCategory.Transform)] +public class CalculateLoomRadius +{ + [Description("The maximum radius of the loom (in centimeters).")] + private float maxRadius = 12.5f; + public float MaxRadius + { + get { return maxRadius; } + set { maxRadius = value; } + } + + [Description("The distance of the subject to the monitor (in centimeters).")] + private float monitorDistance = 18; + public float MonitorDistance + { + get { return monitorDistance; } + set { monitorDistance = value; } + } + + + [Description("The initial radius of the loom (in centimeters).")] + private float initialRadius = 0.5f; + public float InitialRadius + { + get { return initialRadius; } + set { initialRadius = value; } + } + + + [Browsable(false)] + [Description("The initial distance of the virtual loom to the subject (in centimeters).")] + private float initialVirtualDistance = 12.5f; + public float InitialVirtualDistance + { + get { return initialVirtualDistance; } + set { initialVirtualDistance = value; } + } + + [Description("The linear approaching velocity of the virtual looming object (in cm/s).")] + private float linearApproachingVelocity = 25; + public float LinearApproachingVelocity + { + get { return linearApproachingVelocity; } + set { linearApproachingVelocity = value; } + } + + + public IObservable Process(IObservable source) + { + return source.Select(value => { + var t = value > -Single.Epsilon ? -Single.Epsilon : value; + var theta = 2 * Math.Atan(InitialRadius / (-LinearApproachingVelocity * t)); + var radius = Math.Tan(theta/2) * MonitorDistance; + radius = radius > MaxRadius ? MaxRadius : radius; + return (float) radius; + }); + } +} diff --git a/Marta/3MPTracker/src/Extensions/DrawBackground.bonsai b/Marta/3MPTracker/src/Extensions/DrawBackground.bonsai new file mode 100644 index 0000000..fe497a1 --- /dev/null +++ b/Marta/3MPTracker/src/Extensions/DrawBackground.bonsai @@ -0,0 +1,59 @@ + + + + + + Draw + + + BackgroundView + + + + + + Item2 + + + StimulusSettings + + + BackgroundColor + + + + + + + + + + + 2 + 2 + 0 + 0 + -10 + 0 + 1 + 1 + 1 + 1 + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Marta/3MPTracker/src/Extensions/DrawCircleWithNoise.bonsai b/Marta/3MPTracker/src/Extensions/DrawCircleWithNoise.bonsai new file mode 100644 index 0000000..e3b46c9 --- /dev/null +++ b/Marta/3MPTracker/src/Extensions/DrawCircleWithNoise.bonsai @@ -0,0 +1,286 @@ + + + + + + Source1 + + + + + + X + 0.1 + + + + + + + + + + + + + + Transform + + + + Source1 + + + + + + + + + Prepend + 0 + 0 + 0 + + + + + + + + + Prepend + 15 + 15 + 1 + + + + + transform + RandomNoiseCircle + + + + + + + + + + + + + + + + + + + + 0 + + + + + + + + + + + + + 0 + + + + + + + + + + + + + 0 + + + + + + + + + + + + + 1 + + + + + + + + + + 0 + 0 + 0 + 1 + + + + + colorOn + RandomNoiseCircle + + + + + + + + 1 + + + + + + + + + + + + + 1 + + + + + + + + + + + + + 1 + + + + + + + + + + + + + 1 + + + + + + + + + + 1 + 1 + 1 + 1 + + + + + colorOff + RandomNoiseCircle + + + + + + + Value + 0.5 + + + + + + + + + 1 + + + + + contrast + RandomNoiseCircle + + + + + RandomNoiseCircle + Quad + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Marta/3MPTracker/src/Extensions/InferVisualizerViews.cs b/Marta/3MPTracker/src/Extensions/InferVisualizerViews.cs new file mode 100644 index 0000000..fedeb84 --- /dev/null +++ b/Marta/3MPTracker/src/Extensions/InferVisualizerViews.cs @@ -0,0 +1,174 @@ +using Bonsai; +using System; +using System.ComponentModel; +using System.Collections.Generic; +using System.Linq; +using System.Reactive.Linq; +using Bonsai.Sleap; +using OpenCV.Net; + +[Combinator] +[Description("Infers the current view of the subject using the highest confidence of the available bodyparts.")] +[WorkflowElementCategory(ElementCategory.Transform)] +public class InferVisualizerViews +{ + + private string bodyPart_Left = "L"; + public string BodyPart_Left + { + get { return bodyPart_Left; } + set { bodyPart_Left = value; } + } + + private string bodyPart_Right = "R"; + public string BodyPart_Right + { + get { return bodyPart_Right; } + set { bodyPart_Right = value; } + } + + private string bodyPart_Top = "T"; + public string BodyPart_Top + { + get { return bodyPart_Top; } + set { bodyPart_Top = value; } + } + + private string bodyPart_Bottom = "B"; + public string BodyPart_Bottom + { + get { return bodyPart_Bottom; } + set { bodyPart_Bottom = value; } + } + + private string bodyPart_Head = "H"; + public string BodyPart_Head + { + get { return bodyPart_Head; } + set { bodyPart_Head = value; } + } + + private string bodyPart_Thorax = "Trx"; + public string BodyPart_Thorax + { + get { return bodyPart_Thorax; } + set { bodyPart_Thorax = value; } + } + + private string bodyPart_Abdomen = "Abd"; + public string BodyPart_Abdomen + { + get { return bodyPart_Abdomen; } + set { bodyPart_Abdomen = value; } + } + + private string bodyPart_LeftWing = "Lw"; + public string BodyPart_LeftWing + { + get { return bodyPart_LeftWing; } + set { bodyPart_LeftWing = value; } + } + + private string bodyPart_RightWing = "Rw"; + public string BodyPart_RightWing + { + get { return bodyPart_RightWing; } + set { bodyPart_RightWing = value; } + } + + + public IObservable Process(IObservable source) + { + return source.Select(value => { + var bestView = InferBestView(value); + var cleanView = InferCleanView(value, bestView); + var horizonView = InferHorizon(value, cleanView); + return new VisualizerViews() { BestView = bestView, CleanView = cleanView, HorizonView = horizonView}; + }); + } + + static readonly string[] BestViews = { "Left", "Right", "Top", "Bottom" }; + + public InferredView InferBestView(Pose value) + { + BodyPart[] ViewBodyParts = { + value[bodyPart_Left], + value[bodyPart_Right], + value[bodyPart_Top], + value[bodyPart_Bottom]}; + var Confidence = ViewBodyParts.Select(x => x.Confidence).ToArray(); + float MaximumConfidence = Confidence.Max(); + int ArgMax = Array.IndexOf(Confidence, MaximumConfidence); + var BestView = ArgMax == -1 ? string.Empty : BestViews[ArgMax]; + var BestCoordinate = ArgMax == -1 ? new Point2f(float.NaN, float.NaN) : ViewBodyParts[ArgMax].Position; + return new InferredView { ViewName = BestView, Position = BestCoordinate, Confidence = MaximumConfidence }; + } + + public InferredView InferCleanView(Pose value, InferredView bestView) + { + + BodyPart[] ViewBodyParts = { + value[bodyPart_Head], + value[bodyPart_Thorax], + value[bodyPart_Abdomen]}; + var N_visible = ViewBodyParts.Count(bp => !float.IsNaN(bp.Position.X)); + + float conf = float.NaN; + string view = string.Empty; + + if (!float.IsNaN(bestView.Position.X)){ + if (N_visible == 3){ + view = bestView.ViewName; + conf = bestView.Confidence; + } + else{ + view = "Angle"; + conf = 1; + } + } + if (N_visible == 1){ + view = "Vertical"; + conf = 1; + } + else if (N_visible == 2){ + view = "Angle"; + conf = 1; + } + return new InferredView { ViewName = view, Position = bestView.Position, Confidence = conf }; + } + + public Tuple InferHorizon(Pose value, InferredView cleanView){ + + var view = cleanView.ViewName; + + var forwPoint = new Point2f(); + var backPoint = new Point2f(); + + if (view == "Vertical"){ + forwPoint = value[bodyPart_Head].Position; + backPoint = value[bodyPart_Head].Position; + } + else if (view == "Angle"){ + forwPoint = value[bodyPart_Head].Position; + backPoint = value[bodyPart_Abdomen].Position; + } + else{ + forwPoint = cleanView.Position; + backPoint = value[bodyPart_Thorax].Position; + } + + return Tuple.Create(forwPoint, backPoint); + } + + public struct VisualizerViews{ + public InferredView BestView; + public InferredView CleanView; + public Tuple HorizonView; + } + + public struct InferredView{ + public string ViewName; + public Point2f Position; + public float Confidence; + } +} diff --git a/Marta/3MPTracker/src/Extensions/LoadSettings.cs b/Marta/3MPTracker/src/Extensions/LoadSettings.cs new file mode 100644 index 0000000..92cafac --- /dev/null +++ b/Marta/3MPTracker/src/Extensions/LoadSettings.cs @@ -0,0 +1,36 @@ +using Bonsai; +using System; +using System.ComponentModel; +using System.Reactive.Linq; +using YamlDotNet.Serialization; +using System.IO; +using YamlDotNet.Serialization.NamingConventions; +using YamlDotNet.Core; +using AutomaticGenerators; + +[Combinator] +[Description("")] +[WorkflowElementCategory(ElementCategory.Source)] +public class LoadSettings +{ + [Editor("Bonsai.Design.OpenFileNameEditor, Bonsai.Design", DesignTypes.UITypeEditor)] + public string Path { get; set;} + + public IObservable Process() + { + return Observable.Defer(() => + { + BonFlyStimuli settings; + using (var reader = new StreamReader(Path)) + { + var parser = new MergingParser(new Parser(reader)); + + var deserializer = new DeserializerBuilder() + .WithNamingConvention(CamelCaseNamingConvention.Instance) + .Build(); + settings = deserializer.Deserialize(parser); + } + return Observable.Return(settings); + }); + } +} diff --git a/Marta/3MPTracker/src/Extensions/LoomRangeAnimation.bonsai b/Marta/3MPTracker/src/Extensions/LoomRangeAnimation.bonsai new file mode 100644 index 0000000..824fb94 --- /dev/null +++ b/Marta/3MPTracker/src/Extensions/LoomRangeAnimation.bonsai @@ -0,0 +1,111 @@ + + + + + + + + + + + + + + LoomRangeAnimation + + + + + + + + PT0S + + + + + 1 + + + + Duration + + + Duration + + + TotalSeconds + + + + + + + + Duration + + + TotalSeconds + + + + -1 + + + + + + + + + 0.5 + -0.5 + 0 + + + + + + + + + + + 25 + 18 + 0.5 + 12.5 + 25 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Marta/3MPTracker/src/Extensions/NormalizeSleapOutput.cs b/Marta/3MPTracker/src/Extensions/NormalizeSleapOutput.cs new file mode 100644 index 0000000..28e42c3 --- /dev/null +++ b/Marta/3MPTracker/src/Extensions/NormalizeSleapOutput.cs @@ -0,0 +1,62 @@ +using Bonsai; +using System; +using System.ComponentModel; +using System.Collections.Generic; +using System.Linq; +using System.Reactive.Linq; +using Bonsai.Sleap; +using OpenCV.Net; + +[Combinator] +[Description("")] +[WorkflowElementCategory(ElementCategory.Transform)] +public class NormalizeSleapOutput +{ + private Size cropSize; + public Size CropSize + { + get { return cropSize; } + set { cropSize = value; } + } + + [Description("Scaling factor that will be applied after normalizing the positions to the size of the crop.")] + private float scalingFactor = 1; + public float ScalingFactor + { + get { return scalingFactor; } + set { scalingFactor = value; } + } + + + public IObservable Process(IObservable source) + { + return source.Select(value => { + return new NormalizedPose(value, cropSize, scalingFactor); + }); + } + + + + public class NormalizedPose : Pose + { + public NormalizedPose(Pose pose, Size cropSize, float scalingFactor) : base(pose.Image) + { + var normPose = new Pose(this.Image); + normPose.Centroid = this.Centroid; + foreach (var bodypart in pose){ + var normalizedBodyPart = new BodyPart(); + normalizedBodyPart.Name = bodypart.Name; + normalizedBodyPart.Confidence = bodypart.Confidence; + normalizedBodyPart.Position = new Point2f( + bodypart.Position.X / cropSize.Width * scalingFactor, + bodypart.Position.Y / cropSize.Height * scalingFactor + ); + normPose.Add(normalizedBodyPart); + } + Normalized = normPose; + } + + public Pose Normalized { get; set; } + + } +} diff --git a/Marta/3MPTracker/src/Extensions/TurnSyncOff.bonsai b/Marta/3MPTracker/src/Extensions/TurnSyncOff.bonsai new file mode 100644 index 0000000..b3209e1 --- /dev/null +++ b/Marta/3MPTracker/src/Extensions/TurnSyncOff.bonsai @@ -0,0 +1,42 @@ + + + + + + Source1 + + + TurnOffSync + + + + Source1 + + + + false + + + + SyncState + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Marta/3MPTracker/src/Extensions/TurnSyncOn.bonsai b/Marta/3MPTracker/src/Extensions/TurnSyncOn.bonsai new file mode 100644 index 0000000..41034c0 --- /dev/null +++ b/Marta/3MPTracker/src/Extensions/TurnSyncOn.bonsai @@ -0,0 +1,42 @@ + + + + + + Source1 + + + TurnOnSync + + + + Source1 + + + + true + + + + SyncState + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Marta/3MPTracker/src/Extensions/VideoName.bonsai b/Marta/3MPTracker/src/Extensions/VideoName.bonsai new file mode 100644 index 0000000..e03f61f --- /dev/null +++ b/Marta/3MPTracker/src/Extensions/VideoName.bonsai @@ -0,0 +1,59 @@ + + + + + + ThisSessionPaths + + + PostProcessingVideos + + + ThisSessionPaths + + + FileName + + + ArenaVideoStream + + + BackgroundSubtractedFrame.Width + + + BackgroundSubtractedFrame.Height + + + ArenaIndex + + + + + + {2}_w{0}Xh{1} + Item1,Item2,Item3 + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Marta/3MPTracker/src/Extensions/tensorflow.lib b/Marta/3MPTracker/src/Extensions/tensorflow.lib new file mode 100644 index 0000000..93e1bcb Binary files /dev/null and b/Marta/3MPTracker/src/Extensions/tensorflow.lib differ diff --git a/Marta/3MPTracker/src/Extensions/wBackground.frozen_graph.pb b/Marta/3MPTracker/src/Extensions/wBackground.frozen_graph.pb new file mode 100644 index 0000000..a7f65cb Binary files /dev/null and b/Marta/3MPTracker/src/Extensions/wBackground.frozen_graph.pb differ diff --git a/Marta/3MPTracker/src/Extensions/wBackground.training_config.json b/Marta/3MPTracker/src/Extensions/wBackground.training_config.json new file mode 100644 index 0000000..710ac0f --- /dev/null +++ b/Marta/3MPTracker/src/Extensions/wBackground.training_config.json @@ -0,0 +1,2583 @@ +{ + "data": { + "labels": { + "training_labels": "D:/Documents/Bonfly/Bonfly_SLEAP/Merge/Final_Background_2200.v004.slp", + "validation_labels": null, + "validation_fraction": 0.1, + "test_labels": null, + "split_by_inds": false, + "training_inds": [ + 854, + 1154, + 514, + 1445, + 1978, + 757, + 919, + 741, + 500, + 1748, + 1470, + 1155, + 797, + 1850, + 362, + 1957, + 250, + 912, + 739, + 330, + 1233, + 770, + 1287, + 1051, + 970, + 1907, + 97, + 1996, + 1954, + 1122, + 1502, + 1789, + 263, + 1536, + 1801, + 937, + 87, + 865, + 1806, + 2051, + 1639, + 632, + 1136, + 1244, + 1797, + 878, + 1047, + 812, + 101, + 169, + 1139, + 1651, + 601, + 545, + 1406, + 809, + 2050, + 604, + 178, + 130, + 69, + 389, + 765, + 670, + 1440, + 1568, + 133, + 1596, + 360, + 79, + 280, + 1460, + 825, + 763, + 1772, + 1114, + 359, + 73, + 1888, + 94, + 2016, + 58, + 338, + 261, + 960, + 1976, + 2104, + 1333, + 2121, + 639, + 945, + 1301, + 1190, + 1778, + 1130, + 1390, + 631, + 384, + 1284, + 963, + 1855, + 213, + 906, + 1452, + 2045, + 808, + 968, + 407, + 628, + 281, + 1176, + 941, + 455, + 2093, + 1722, + 329, + 1873, + 8, + 182, + 350, + 75, + 1599, + 1538, + 167, + 207, + 283, + 149, + 1796, + 1884, + 1744, + 553, + 1226, + 366, + 1009, + 427, + 1472, + 1477, + 308, + 659, + 1471, + 423, + 1512, + 790, + 1861, + 679, + 2195, + 170, + 1262, + 259, + 1282, + 1908, + 241, + 1511, + 132, + 29, + 1041, + 1171, + 454, + 1998, + 185, + 1557, + 497, + 364, + 590, + 1082, + 1951, + 1540, + 785, + 333, + 1140, + 582, + 1895, + 749, + 1251, + 695, + 31, + 1469, + 1847, + 1909, + 1409, + 1695, + 983, + 1014, + 482, + 1823, + 710, + 1117, + 425, + 2197, + 2025, + 229, + 6, + 127, + 921, + 1878, + 1589, + 176, + 1767, + 1058, + 1276, + 1278, + 61, + 2158, + 470, + 2097, + 1054, + 951, + 1968, + 1490, + 1694, + 1736, + 437, + 516, + 1942, + 1426, + 1597, + 33, + 1945, + 720, + 826, + 657, + 1088, + 904, + 903, + 1338, + 240, + 643, + 1773, + 388, + 300, + 307, + 1953, + 1083, + 529, + 1564, + 2049, + 1497, + 312, + 1514, + 925, + 1910, + 244, + 1714, + 1020, + 1123, + 38, + 2047, + 1862, + 2181, + 509, + 1098, + 998, + 1994, + 289, + 675, + 563, + 2151, + 1070, + 1793, + 2149, + 1585, + 1179, + 654, + 1018, + 1549, + 22, + 608, + 1036, + 1125, + 1213, + 121, + 918, + 799, + 445, + 1309, + 609, + 1576, + 463, + 1173, + 1037, + 1281, + 1240, + 824, + 1897, + 1353, + 872, + 1745, + 12, + 1854, + 1699, + 301, + 2005, + 1056, + 63, + 82, + 1673, + 894, + 1231, + 1686, + 110, + 2172, + 1515, + 984, + 1080, + 2169, + 252, + 2165, + 1388, + 2167, + 1534, + 1558, + 1955, + 1613, + 923, + 734, + 370, + 433, + 1531, + 1667, + 1297, + 1930, + 1614, + 28, + 404, + 2042, + 1187, + 418, + 581, + 2103, + 1963, + 93, + 107, + 1150, + 421, + 768, + 284, + 72, + 1993, + 1655, + 697, + 1753, + 1332, + 1712, + 2065, + 1982, + 993, + 416, + 642, + 1918, + 1335, + 1064, + 125, + 1034, + 2179, + 1055, + 1365, + 1890, + 1741, + 78, + 2084, + 165, + 1342, + 83, + 272, + 1068, + 204, + 1165, + 108, + 1184, + 15, + 1422, + 2100, + 726, + 1565, + 922, + 1513, + 1376, + 351, + 1419, + 150, + 1705, + 1197, + 982, + 1118, + 2190, + 961, + 1620, + 1290, + 1811, + 1702, + 1503, + 1115, + 19, + 2063, + 756, + 1836, + 2130, + 319, + 70, + 1521, + 236, + 1691, + 1069, + 147, + 35, + 2024, + 189, + 1237, + 304, + 1715, + 1180, + 1386, + 1848, + 1986, + 336, + 1958, + 1209, + 725, + 1121, + 1483, + 1158, + 1384, + 979, + 1012, + 518, + 54, + 1630, + 1375, + 1817, + 1039, + 867, + 625, + 2119, + 560, + 855, + 473, + 186, + 1090, + 74, + 1193, + 517, + 498, + 1834, + 206, + 2029, + 396, + 1827, + 1350, + 946, + 1650, + 2131, + 188, + 439, + 34, + 230, + 1619, + 1750, + 1631, + 1013, + 398, + 1883, + 1794, + 1703, + 1687, + 2001, + 594, + 1293, + 613, + 1200, + 1509, + 889, + 773, + 2143, + 442, + 694, + 1710, + 1904, + 205, + 160, + 21, + 1010, + 599, + 446, + 869, + 664, + 365, + 1720, + 209, + 572, + 862, + 1393, + 1, + 2030, + 570, + 390, + 606, + 1685, + 1112, + 401, + 834, + 1906, + 1367, + 1198, + 1869, + 2187, + 1252, + 1275, + 354, + 228, + 2192, + 508, + 1588, + 1102, + 1911, + 2161, + 1633, + 1214, + 143, + 740, + 2186, + 750, + 184, + 104, + 1670, + 2101, + 2122, + 1700, + 1021, + 1326, + 1572, + 2185, + 2034, + 251, + 678, + 383, + 18, + 1042, + 1505, + 98, + 2145, + 816, + 2109, + 37, + 24, + 231, + 1743, + 1637, + 641, + 1774, + 630, + 114, + 892, + 457, + 1566, + 1387, + 627, + 1395, + 849, + 322, + 2191, + 197, + 1995, + 821, + 2071, + 1006, + 817, + 928, + 541, + 451, + 607, + 542, + 353, + 1465, + 2125, + 1690, + 565, + 1837, + 1443, + 2108, + 1228, + 1805, + 2085, + 1763, + 1770, + 637, + 1454, + 26, + 211, + 476, + 1315, + 818, + 585, + 10, + 1979, + 546, + 1607, + 492, + 1849, + 156, + 453, + 1357, + 477, + 1701, + 738, + 814, + 1626, + 1604, + 1086, + 405, + 1428, + 715, + 674, + 931, + 180, + 1004, + 1510, + 271, + 1432, + 1740, + 196, + 1879, + 2091, + 882, + 1295, + 488, + 793, + 1683, + 655, + 1601, + 59, + 1581, + 1285, + 1764, + 2082, + 801, + 358, + 871, + 940, + 957, + 776, + 1735, + 102, + 2178, + 2046, + 2138, + 616, + 1135, + 1259, + 2168, + 1885, + 2188, + 718, + 1157, + 1544, + 155, + 415, + 2077, + 1002, + 791, + 400, + 1575, + 1675, + 1946, + 879, + 1603, + 126, + 561, + 238, + 321, + 275, + 614, + 848, + 264, + 1201, + 1845, + 422, + 1625, + 67, + 1612, + 962, + 466, + 841, + 2170, + 1437, + 452, + 1061, + 1556, + 1754, + 743, + 123, + 933, + 394, + 1826, + 1519, + 258, + 1761, + 368, + 105, + 9, + 788, + 1405, + 863, + 810, + 265, + 1539, + 468, + 1760, + 1664, + 677, + 56, + 784, + 1363, + 1825, + 2126, + 1356, + 510, + 249, + 1196, + 1100, + 426, + 1586, + 1159, + 2128, + 1580, + 1739, + 1727, + 1134, + 1362, + 1156, + 1689, + 1841, + 1840, + 1453, + 138, + 1833, + 1622, + 201, + 633, + 924, + 988, + 1508, + 1608, + 938, + 914, + 162, + 1024, + 1269, + 1358, + 829, + 1084, + 1015, + 25, + 1656, + 2035, + 760, + 727, + 1261, + 1402, + 1067, + 1786, + 1704, + 172, + 17, + 1868, + 1430, + 846, + 1708, + 796, + 605, + 971, + 775, + 1337, + 1178, + 1073, + 1813, + 663, + 210, + 742, + 574, + 1971, + 999, + 399, + 95, + 1542, + 1819, + 1031, + 1821, + 1529, + 349, + 2086, + 297, + 598, + 1219, + 900, + 1172, + 944, + 1600, + 1369, + 1265, + 217, + 876, + 171, + 660, + 1417, + 161, + 177, + 1412, + 985, + 754, + 1271, + 1688, + 1132, + 995, + 525, + 2113, + 1026, + 1129, + 489, + 1913, + 1480, + 566, + 1804, + 1311, + 1765, + 1985, + 1696, + 1669, + 1967, + 1316, + 1421, + 668, + 619, + 1584, + 266, + 1011, + 168, + 208, + 523, + 861, + 2018, + 1491, + 615, + 1145, + 1400, + 1238, + 1256, + 154, + 1420, + 1066, + 1992, + 2146, + 1195, + 1791, + 1977, + 1755, + 1578, + 1932, + 1224, + 673, + 700, + 1094, + 978, + 2105, + 1648, + 1107, + 721, + 932, + 1313, + 1127, + 2059, + 992, + 571, + 1407, + 1646, + 239, + 51, + 1984, + 1838, + 1354, + 1128, + 1852, + 367, + 417, + 340, + 1325, + 116, + 1899, + 86, + 302, + 758, + 221, + 1191, + 881, + 1808, + 175, + 1217, + 164, + 1022, + 1990, + 324, + 1711, + 1816, + 873, + 450, + 372, + 1642, + 120, + 1997, + 1435, + 1870, + 2112, + 2057, + 1730, + 2076, + 371, + 1507, + 148, + 1436, + 1372, + 1227, + 1153, + 1092, + 1425, + 1657, + 1940, + 1846, + 917, + 858, + 2135, + 44, + 32, + 2066, + 447, + 1592, + 909, + 1075, + 1273, + 1636, + 109, + 762, + 1481, + 1653, + 930, + 729, + 507, + 1660, + 1893, + 1382, + 344, + 2003, + 1679, + 145, + 511, + 1771, + 337, + 662, + 1457, + 1210, + 967, + 1551, + 36, + 1028, + 897, + 2171, + 282, + 234, + 1493, + 1371, + 913, + 2039, + 223, + 84, + 253, + 1950, + 929, + 667, + 276, + 1749, + 714, + 629, + 491, + 2147, + 1467, + 496, + 1396, + 1731, + 1399, + 1623, + 1532, + 1961, + 1113, + 137, + 990, + 71, + 1820, + 779, + 558, + 794, + 1541, + 1416, + 2021, + 1871, + 1060, + 2070, + 1147, + 1149, + 819, + 1518, + 1174, + 461, + 1734, + 1126, + 538, + 153, + 1062, + 644, + 474, + 1368, + 1392, + 1164, + 1411, + 737, + 767, + 996, + 2148, + 1988, + 52, + 2006, + 227, + 1450, + 981, + 1248, + 870, + 943, + 838, + 385, + 1141, + 88, + 1071, + 1242, + 1787, + 481, + 181, + 2155, + 306, + 1609, + 311, + 2087, + 1553, + 382, + 1439, + 1798, + 745, + 1330, + 191, + 1045, + 163, + 1528, + 64, + 649, + 1466, + 225, + 1863, + 723, + 141, + 1255, + 314, + 1501, + 2156, + 1559, + 2133, + 843, + 1692, + 1459, + 1038, + 267, + 1839, + 315, + 2055, + 780, + 48, + 334, + 1329, + 936, + 836, + 1678, + 1915, + 1288, + 328, + 2096, + 2173, + 1912, + 146, + 90, + 115, + 974, + 1250, + 1175, + 1035, + 1444, + 2132, + 255, + 55, + 840, + 1938, + 256, + 717, + 1638, + 2054, + 2075, + 916, + 898, + 3, + 1033, + 1527, + 42, + 761, + 471, + 557, + 2176, + 976, + 495, + 1486, + 472, + 724, + 603, + 1875, + 363, + 1537, + 828, + 587, + 2062, + 346, + 1379, + 1652, + 1903, + 827, + 411, + 1462, + 378, + 260, + 676, + 49, + 1526, + 1448, + 1346, + 1264, + 183, + 832, + 1336, + 589, + 467, + 279, + 1872, + 1936, + 577, + 331, + 1003, + 1473, + 706, + 247, + 1803, + 1243, + 2037, + 81, + 847, + 1258, + 535, + 959, + 1874, + 1757, + 1280, + 691, + 1001, + 305, + 1433, + 1933, + 326, + 1562, + 2083, + 1965, + 888, + 1079, + 1317, + 2094, + 245, + 2123, + 635, + 2164, + 373, + 539, + 1928, + 435, + 1775, + 2124, + 1824, + 612, + 856, + 1398, + 1008, + 1215, + 520, + 653, + 519, + 117, + 622, + 2116, + 1799, + 1495, + 429, + 2031, + 1920, + 652, + 140, + 129, + 215, + 1347, + 1947, + 2022, + 671, + 777, + 1617, + 1166, + 732, + 112, + 1674, + 2134, + 1707, + 1364, + 1929, + 1643, + 1414, + 369, + 142, + 805, + 1768, + 1941, + 556, + 403, + 345, + 1822, + 1324, + 684, + 316, + 53, + 1602, + 323, + 487, + 1076, + 1449, + 1896, + 600, + 465, + 409, + 190, + 113, + 432, + 174, + 2095, + 1341, + 1717, + 379, + 596, + 755, + 1550, + 278, + 1023, + 1960, + 524, + 1230, + 46, + 753, + 348, + 1973, + 1925, + 2110, + 1299, + 747, + 1516, + 1109, + 1451, + 2020, + 1052, + 1668, + 1476, + 857, + 1865, + 212, + 1204, + 1723, + 2117, + 13, + 1654, + 1991, + 575, + 1138, + 815, + 1458, + 1627, + 1212, + 647, + 1916, + 502, + 203, + 1207, + 576, + 597, + 342, + 1665, + 880, + 1307, + 965, + 2011, + 713, + 1032, + 1050, + 413, + 2196, + 1167, + 246, + 484, + 1843, + 1434, + 1881, + 2089, + 769, + 2175, + 1725, + 195, + 335, + 915, + 515, + 711, + 490, + 232, + 620, + 2032, + 1192, + 891, + 885, + 434, + 1182, + 1065, + 1496, + 730, + 235, + 99, + 1059, + 1952, + 1348, + 1424, + 193, + 430, + 1381, + 1706, + 764, + 179, + 464, + 1239, + 1579, + 977, + 1860, + 1676, + 1016, + 62, + 501, + 1732, + 144, + 443, + 424, + 1810, + 1300, + 1349, + 1378, + 544, + 1999, + 41, + 1517, + 537, + 2013, + 1355, + 1632, + 2118, + 1595, + 2144, + 325, + 2052, + 1078, + 1530, + 2012, + 975, + 1319, + 1091, + 1345, + 1110, + 1905, + 1283, + 1461, + 580, + 902, + 1921, + 617, + 733, + 1007, + 131, + 1442, + 1124, + 973, + 1429, + 661, + 43, + 1956, + 1202, + 1983, + 2189, + 1641, + 410, + 680, + 1587, + 935, + 1561, + 1611, + 1205, + 1830, + 1160, + 1072, + 60, + 1208, + 689, + 1590, + 30, + 159, + 2127, + 420, + 1886, + 1320, + 837, + 1681, + 1310, + 1747, + 1832, + 1962, + 1663, + 1752, + 480, + 549, + 248, + 1975, + 1389, + 1223, + 787, + 964, + 392, + 696, + 1782, + 1889, + 1029, + 218, + 831, + 1085, + 1829, + 222, + 377, + 436, + 1815, + 1492, + 1218, + 2139, + 395, + 1970, + 1987, + 1485, + 1533, + 1733, + 1554, + 2027, + 505, + 100, + 997, + 2184, + 1268, + 1972, + 1235, + 1858, + 1853, + 896, + 752, + 685, + 2114, + 1203, + 2141, + 1321, + 744, + 704, + 2007, + 1144, + 2079, + 895, + 1186, + 478, + 1866, + 202, + 1867, + 1101, + 1800, + 1900, + 1624, + 709, + 1523, + 2159, + 835, + 1116, + 1844, + 243, + 966, + 1959, + 1729, + 1199, + 1552, + 1340, + 540, + 634, + 1000, + 199, + 1361, + 2014, + 751, + 1980, + 1697, + 1063, + 356, + 1318, + 820, + 1506, + 1802, + 173, + 1593, + 1594, + 1618, + 1446, + 1756, + 731, + 1577, + 233, + 374, + 2002, + 1274, + 254, + 1189, + 2026, + 318, + 1403, + 802, + 911, + 1621, + 1488, + 1682, + 823, + 584, + 136, + 534, + 735, + 20, + 621, + 92, + 45, + 1842, + 972, + 950, + 1716, + 5, + 2043, + 934, + 842, + 387, + 1658, + 640, + 1877, + 994, + 1742, + 886, + 586, + 528, + 1922, + 1277, + 1312, + 1926, + 953, + 1758, + 1573, + 268, + 1106, + 504, + 1291, + 1659, + 291, + 2153, + 1105, + 1751, + 1236, + 2152, + 666, + 1438, + 1917, + 1119, + 449, + 952, + 1418, + 877, + 1391, + 2080, + 759, + 2142, + 875, + 1571, + 860, + 1746, + 656, + 1788, + 1093, + 942, + 552, + 462, + 1327, + 1644, + 431, + 798, + 1162, + 402, + 1464, + 1645, + 339, + 1374, + 386, + 2019, + 1046, + 687, + 1535, + 237, + 1974, + 166, + 1302, + 293, + 1776, + 698, + 782, + 376, + 50, + 1726, + 1795, + 327, + 458, + 692, + 2072, + 1828, + 688, + 1111, + 1279, + 1131, + 2058, + 646, + 868, + 593, + 216, + 1019, + 2048, + 299, + 47, + 85, + 298, + 1404, + 286, + 699, + 1671, + 907, + 939, + 187, + 1934, + 866, + 2106, + 296, + 1790, + 1334, + 1137, + 1719, + 1784, + 139, + 295, + 1548, + 1661, + 807, + 1522, + 1221, + 1216, + 290, + 1272, + 890, + 1385, + 626, + 1339, + 844, + 419, + 1966, + 789, + 947, + 850, + 1721, + 969, + 893, + 1500, + 1792, + 198, + 1475, + 2137, + 440, + 77, + 1499, + 1408, + 1163, + 1410, + 748, + 1662, + 948, + 899, + 573, + 650, + 1380, + 313, + 493, + 1077, + 1546, + 2041, + 701, + 1415, + 1294, + 991, + 543, + 1246, + 219, + 428, + 287, + 569, + 2157, + 1831, + 357, + 294, + 567, + 1266, + 1304, + 1944, + 532, + 1152, + 1487, + 583, + 122, + 499, + 1738, + 1222, + 1574, + 1628, + 1185, + 39, + 1247, + 954, + 483, + 1859, + 257, + 1096, + 303, + 702, + 783, + 774, + 341, + 591, + 1777, + 1087, + 475, + 1647, + 292, + 1456, + 1359, + 1305, + 1151, + 1606, + 391, + 2074, + 1296, + 1563, + 2129, + 568, + 2060, + 884, + 1693, + 2198, + 1709, + 746, + 910, + 1027, + 274, + 1463, + 220, + 317, + 1478, + 1880, + 1427, + 332, + 859, + 1598, + 1441, + 1005, + 1170, + 690, + 1030, + 1634, + 503, + 397, + 708, + 1351, + 103, + 1616, + 1146, + 1567, + 1479, + 1360, + 226, + 1161, + 1254, + 106, + 1713, + 1809, + 157, + 2078, + 1728, + 1520, + 1225, + 1902, + 200, + 693, + 118, + 1234, + 375, + 1939, + 1680, + 2067, + 352, + 2061, + 288, + 1025, + 1043, + 76, + 1366, + 1298, + 1489, + 562, + 1097, + 521, + 1044, + 1120, + 192, + 1253, + 456, + 559, + 1737, + 578, + 1927, + 65, + 494, + 2000, + 1394, + 874, + 224, + 320, + 1785, + 1482, + 926, + 987, + 527, + 1095, + 2069, + 2090, + 636, + 624, + 579, + 1864, + 1857, + 448, + 1177, + 803, + 811, + 2044, + 1629, + 722, + 1232, + 1818, + 901, + 1104, + 786, + 1666, + 736, + 135, + 1267, + 128, + 2136, + 669, + 1220, + 1759, + 2015, + 554, + 1525, + 2056, + 1308, + 822, + 550, + 2038, + 1343, + 2033, + 781, + 57, + 547, + 1856, + 485, + 989, + 1781, + 1779, + 309, + 1892, + 1635, + 68, + 111, + 1397, + 1923, + 522, + 852, + 96, + 1891, + 1133, + 438, + 1935, + 2107, + 1241, + 1524, + 2183, + 2194, + 2140, + 441, + 1605, + 533, + 683, + 1142, + 771, + 1543, + 833, + 1263, + 611, + 1560, + 1780, + 1413, + 864, + 2023, + 1649, + 792, + 152, + 277, + 1322, + 4, + 813, + 1981, + 1103, + 1901, + 1081, + 2177, + 839, + 1089, + 766, + 1718, + 242, + 2008, + 1099, + 2088, + 1698 + ], + "validation_inds": [ + 1969, + 658, + 1783, + 134, + 986, + 555, + 800, + 1314, + 460, + 531, + 1924, + 1040, + 2160, + 806, + 194, + 1931, + 1851, + 1894, + 1148, + 1914, + 955, + 1474, + 479, + 1323, + 2102, + 2162, + 665, + 1591, + 2004, + 686, + 1447, + 623, + 1289, + 285, + 1053, + 795, + 705, + 214, + 1377, + 778, + 2081, + 2, + 1555, + 1762, + 1812, + 119, + 270, + 1206, + 1882, + 151, + 1949, + 2174, + 530, + 91, + 2009, + 592, + 1989, + 1547, + 949, + 1257, + 712, + 648, + 1229, + 23, + 1610, + 1401, + 2010, + 1181, + 2073, + 1168, + 1545, + 1331, + 707, + 905, + 703, + 40, + 564, + 1948, + 2068, + 444, + 2099, + 1169, + 1423, + 1569, + 1286, + 273, + 1504, + 2111, + 381, + 672, + 1211, + 269, + 651, + 883, + 1876, + 1724, + 1048, + 1270, + 804, + 536, + 66, + 887, + 2120, + 2036, + 1074, + 89, + 1057, + 158, + 408, + 1677, + 588, + 1887, + 1769, + 645, + 1583, + 406, + 2163, + 80, + 548, + 486, + 2028, + 526, + 1943, + 412, + 310, + 1352, + 1919, + 1494, + 2040, + 361, + 1835, + 2053, + 1188, + 347, + 638, + 124, + 16, + 1306, + 851, + 1328, + 14, + 1183, + 1049, + 2115, + 1640, + 1898, + 2092, + 1260, + 380, + 355, + 27, + 1498, + 920, + 1194, + 1373, + 845, + 414, + 513, + 469, + 1484, + 1937, + 2182, + 1383, + 1814, + 1455, + 2166, + 1766, + 728, + 2193, + 1249, + 1143, + 1108, + 830, + 602, + 2017, + 595, + 980, + 1582, + 506, + 1468, + 610, + 1615, + 393, + 681, + 0, + 1684, + 719, + 1245, + 853, + 2150, + 551, + 2154, + 956, + 1964, + 1303, + 2199, + 908, + 618, + 1292, + 1370, + 1431, + 1672, + 459, + 7, + 1017, + 2098, + 262, + 927, + 512, + 1570, + 958, + 2180, + 1807, + 2064, + 11, + 772, + 1344, + 343, + 716, + 682 + ], + "test_inds": null, + "search_path_hints": [ + "" + ], + "skeletons": [ + { + "directed": true, + "graph": { + "name": "Skeleton-2", + "num_edges_inserted": 47 + }, + "links": [ + { + "key": 0, + "source": { + "py/object": "sleap.skeleton.Node", + "py/state": { + "py/tuple": [ + "Left", + 1.0 + ] + } + }, + "target": { + "py/object": "sleap.skeleton.Node", + "py/state": { + "py/tuple": [ + "Right", + 1.0 + ] + } + }, + "type": { + "py/reduce": [ + { + "py/type": "sleap.skeleton.EdgeType" + }, + { + "py/tuple": [ + 2 + ] + } + ] + } + }, + { + "key": 0, + "source": { + "py/id": 2 + }, + "target": { + "py/id": 1 + }, + "type": { + "py/id": 3 + } + }, + { + "edge_insert_idx": 43, + "key": 0, + "source": { + "py/object": "sleap.skeleton.Node", + "py/state": { + "py/tuple": [ + "Thorax", + 1.0 + ] + } + }, + "target": { + "py/object": "sleap.skeleton.Node", + "py/state": { + "py/tuple": [ + "Top", + 1.0 + ] + } + }, + "type": { + "py/reduce": [ + { + "py/type": "sleap.skeleton.EdgeType" + }, + { + "py/tuple": [ + 1 + ] + } + ] + } + }, + { + "edge_insert_idx": 44, + "key": 0, + "source": { + "py/id": 4 + }, + "target": { + "py/id": 1 + }, + "type": { + "py/id": 6 + } + }, + { + "edge_insert_idx": 45, + "key": 0, + "source": { + "py/id": 4 + }, + "target": { + "py/id": 2 + }, + "type": { + "py/id": 6 + } + }, + { + "key": 0, + "source": { + "py/object": "sleap.skeleton.Node", + "py/state": { + "py/tuple": [ + "LeftWing", + 1.0 + ] + } + }, + "target": { + "py/object": "sleap.skeleton.Node", + "py/state": { + "py/tuple": [ + "RightWing", + 1.0 + ] + } + }, + "type": { + "py/id": 3 + } + }, + { + "key": 0, + "source": { + "py/id": 8 + }, + "target": { + "py/id": 7 + }, + "type": { + "py/id": 3 + } + } + ], + "multigraph": true, + "nodes": [ + { + "id": { + "py/id": 1 + } + }, + { + "id": { + "py/id": 2 + } + }, + { + "id": { + "py/object": "sleap.skeleton.Node", + "py/state": { + "py/tuple": [ + "Head", + 1.0 + ] + } + } + }, + { + "id": { + "py/id": 4 + } + }, + { + "id": { + "py/id": 7 + } + }, + { + "id": { + "py/id": 8 + } + }, + { + "id": { + "py/id": 5 + } + }, + { + "id": { + "py/object": "sleap.skeleton.Node", + "py/state": { + "py/tuple": [ + "Abdomen", + 1.0 + ] + } + } + } + ] + } + ] + }, + "preprocessing": { + "ensure_rgb": false, + "ensure_grayscale": false, + "imagenet_mode": null, + "input_scaling": 1.0, + "pad_to_stride": 16, + "resize_and_pad_to_target": true, + "target_height": 128, + "target_width": 128 + }, + "instance_cropping": { + "center_on_part": null, + "crop_size": null, + "crop_size_detection_padding": 16 + } + }, + "model": { + "backbone": { + "leap": null, + "unet": { + "stem_stride": null, + "max_stride": 16, + "output_stride": 2, + "filters": 16, + "filters_rate": 2.0, + "middle_block": true, + "up_interpolate": true, + "stacks": 1 + }, + "hourglass": null, + "resnet": null, + "pretrained_encoder": null + }, + "heads": { + "single_instance": { + "part_names": [ + "Left", + "Right", + "Head", + "Thorax", + "LeftWing", + "RightWing", + "Top", + "Abdomen" + ], + "sigma": 2.5, + "output_stride": 2, + "loss_weight": 1.0, + "offset_refinement": false + }, + "centroid": null, + "centered_instance": null, + "multi_instance": null, + "multi_class_bottomup": null, + "multi_class_topdown": null + } + }, + "optimization": { + "preload_data": true, + "augmentation_config": { + "rotate": true, + "rotation_min_angle": -180.0, + "rotation_max_angle": 180.0, + "translate": false, + "translate_min": -5, + "translate_max": 5, + "scale": true, + "scale_min": 0.4, + "scale_max": 3.1, + "uniform_noise": true, + "uniform_noise_min_val": 0.0, + "uniform_noise_max_val": 10.0, + "gaussian_noise": true, + "gaussian_noise_mean": 7.0, + "gaussian_noise_stddev": 1.0, + "contrast": true, + "contrast_min_gamma": 0.25, + "contrast_max_gamma": 2.5, + "brightness": true, + "brightness_min_val": 0.0, + "brightness_max_val": 10.0, + "random_crop": false, + "random_crop_height": 256, + "random_crop_width": 256, + "random_flip": false, + "flip_horizontal": true + }, + "online_shuffling": true, + "shuffle_buffer_size": 128, + "prefetch": true, + "batch_size": 7, + "batches_per_epoch": 282, + "min_batches_per_epoch": 200, + "val_batches_per_epoch": 31, + "min_val_batches_per_epoch": 10, + "epochs": 999, + "optimizer": "adam", + "initial_learning_rate": 0.0001, + "learning_rate_schedule": { + "reduce_on_plateau": true, + "reduction_factor": 0.5, + "plateau_min_delta": 1e-06, + "plateau_patience": 5, + "plateau_cooldown": 3, + "min_learning_rate": 1e-08 + }, + "hard_keypoint_mining": { + "online_mining": false, + "hard_to_easy_ratio": 2.0, + "min_hard_keypoints": 2, + "max_hard_keypoints": null, + "loss_scale": 5.0 + }, + "early_stopping": { + "stop_training_on_plateau": true, + "plateau_min_delta": 1e-08, + "plateau_patience": 99 + } + }, + "outputs": { + "save_outputs": true, + "run_name": "240819_202332.single_instance.n=2200", + "run_name_prefix": "", + "run_name_suffix": "", + "runs_folder": "D:/Documents/Bonfly/Bonfly_SLEAP/Merge\\models", + "tags": [ + "" + ], + "save_visualizations": true, + "delete_viz_images": true, + "zip_outputs": false, + "log_to_csv": true, + "checkpointing": { + "initial_model": false, + "best_model": true, + "every_epoch": false, + "latest_model": false, + "final_model": false + }, + "tensorboard": { + "write_logs": false, + "loss_frequency": "epoch", + "architecture_graph": false, + "profile_graph": false, + "visualizations": true + }, + "zmq": { + "subscribe_to_controller": true, + "controller_address": "tcp://127.0.0.1:9000", + "controller_polling_timeout": 10, + "publish_updates": true, + "publish_address": "tcp://127.0.0.1:9001" + } + }, + "name": "", + "description": "", + "sleap_version": "1.2.9", + "filename": "D:/Documents/Bonfly/Bonfly_SLEAP/Merge\\models\\240819_202332.single_instance.n=2200\\training_config.json" +} \ No newline at end of file