Skip to content

Instantly share code, notes, and snippets.

View atuleu's full-sized avatar

Alexandre Tuleu atuleu

  • Biorob - EPFL
  • Lausanne, Switzerland
View GitHub Profile
@atuleu
atuleu / clone_ant_shape.R
Last active August 11, 2020 16:36
#FortMyrmidon clone shape accross file
library(FortMyrmidon)
#find a given fmCAnt in an experiment given its ID
findCAnt <- function(e,antID) {
ants <- e$cAnts();
ants$objects[[which(ants$summary$antID == antID)]]
}
# clone the ant shape types from one experiment to another
cloneShapeTypes <- function(from,to) {
@atuleu
atuleu / user_defined_ant_pose.R
Last active June 15, 2020 19:49
#FortMyrmidon Set Ant orientation manually
e <- fmExperimentOpen("file.myrmidon")
ts <- fmQueryComputeTagStatistics()
for ( i in seq(1,length(ts))) {
# optionnaly maybe skip the tag with some criterion
if ( ts[i]$Count < 42 ) {
next;
}
a <- e$createAnt();
@atuleu
atuleu / compute_ant_position.R
Last active June 15, 2020 19:34
#FortMyrmidon Compute instantaneous positions for every ant between two times
library(fortMyrmidon)
# load an experiment file, the one with the Bees
e <- fmExperimentOpenReadOnly("myfile.myrmidon")
# queries all positions of bees between that two times, and do not ask for their zones (they are none defined)
positions <- fmQueryIdentifyFrames(e,
start = fmTimeParse('2020-05-14T08:00:00.000Z'),
end = fmTimeParse('2020-05-14T09:00:00.000Z'),
reportZone = FALSE);
@atuleu
atuleu / compute_interaction_between_two_times.R
Last active June 18, 2020 09:07
#FortMyrmidon Compute interaction between two time
# One can use fmExperimentOpenReadOnly too if no modification are needed.
e<-fmExperimentOpen("myfile.myrmidon")
# start or end can be POSIXct, fmTime or fmTimeCptr object. But they cannot just be character vector.
interactions <- fmQueryComputeAntInteractions(e,
start = fmTimeParse("2020-02-11T11:53:26.790610Z"),
end = fmTimeParse("2020-02-11T12:53:52.685287Z"),
maximumGap = fmMillisecond(800), # 800ms gap in interaction are allowed
reportTrajectories = FALSE, # you may set true but it will be slower
singleThreaded = FALSE) # you can try true to check performances
# Please check d
@atuleu
atuleu / compute_tag_rate.R
Last active June 17, 2020 18:41
#FortMyrmidon Compute the rate of apparition for tags
e <- fmExperimentOpenReadOnly("file.myrmidon")
nbFrames <- e$getDataInformations()$frames
ts <- fmQueryComputeTagStatistics(e)
ts$CountRate <- ts$Count / nbFrames
@atuleu
atuleu / automatic_ant_creation.R
Created June 15, 2020 19:16
#FortMyrmidon How to create tag automatically for Ants
library(fortMyrmidon)
e <- fmExperimentOpen("filename.myrmidon")
ts <- fmQueryComputeTagStatistics(e)
for ( i in seq(1,length(ts))) {
a <- e$createAnt()
e$addIdentification(a$antID(),ts[i]$TagID,fmTimeInf(),fmTimeInf())
}
@atuleu
atuleu / .bashrc
Last active January 6, 2016 14:26
Funny prompt with zodiac sign
# This is a funny prompt that would display the zodiac sign corresponding to the date of creation (date when the file is sourced)
# computes the right UTF-8 zodiac sign from today's date
function __today_zodiac
{
local today=$(date +%m%d)
if [ $today -le 0120 ]
then
sign=$'\u2651' # "capricorn"