Code Monkey home page Code Monkey logo

pambinaries's Introduction

R-CMD-check

PamBinaries

The PamBinaries package is a set of functions for reading PAMGuard binary output (.pgdf files) into R. It is based on MATLAB functions created by Doug Gillespie and Michael Oswald, and is written to work in the same way.

Installation

PamBinaries is available on CRAN, but it is possible that a more recent version is available on GitHub (updates are typically rare for this package).

To install the latest version from GitHub:

# make sure you have Rtools installed
if(!require('devtools')) install.packages('devtools')
# install from GitHub
devtools::install_github('TaikiSan21/PamBinaries')

Tutorial

The main function of this package is loadPamguardBinaryFile.

To read any PAMGuard binary file, just point this function to its location:

myBinaryFile <- './Files/SomeBinaryFile.pgdf'
binaryData <- loadPamguardBinaryFile(myBinaryFile)

loadPamguardBinaryFile will automatically determine the type of data stored in the binary file (Click Detector, DIFAR Processing, etc.) and call the appropriate function.

binaryData is a list with two objects, data and fileInfo. binaryData$data is a list with one element for every individual item in the binary file, the contents of which will be different depending on the type of binary file being read. binaryData$fileInfo is a list containing some metadata and information used by the loadPamguardBinaryFile function.

There is also an option to reduce the size of objects read from a Click Detector, Whistle and Moan Detector, or DIFAR:

binaryDataSmall <- loadPamguardBinaryFile(myBinaryFile, skipLarge=TRUE)

This option will skip reading the waveform for click and difar data, and skip the contour and slice information for whistle data. This greatly reduces the size of the loaded object and the time required to read the data, useful if you need to process a large number of files.

You can also choose to only read in data with specific UIDs:

binarySomeUIDs <- loadPamguardBinaryFile(myBinaryFile, keepUIDs=c(100000001, 100000002))

This only read in the data with the UIDs provided in the keepUIDs argument, skipping over the rest. This can greatly reduce the time required to read data if you only need a small subset of the items in the binary file.

As of version 1.2 there is a second exported function, pbToDf. This function converts the output of loadPamguardBinaryFile into a data frame. In order to do this it must skip some of the information in the binaries that are not an appropriate size to put in a data frame, as of version 1.2 the skipped data includes: any annotations data, click wave forms, DIFAR demux data, and contour information from the Whistle & Moan Detector. This function can be called directly, and is also called when as.data.frame is called on an object of class PamBinary; the output of loadPamguardBinaryFile is both list and PamBinary as of version 1.2.

The following should return identical results:

df1 <- pbToDf(binaryData)
df2 <- as.data.frame(binaryData)
df3 <- data.frame(binaryData)
df4 <- pbToDf(binaryData$data)

The final example (df4) is not the preferred way to make this conversion, but is included to avoid possibly surprising behavior. The function will issue a warning, but will convert to a data frame as expected.

Compatibility

PamBinaries should be compatible with Pamguard v2.00.15 and earlier.

TO DO:

Add rest of annotation readers. Will probably need to re-adjust existing ones in future PG versions.

Cant install if no current timezone

pambinaries's People

Contributors

taikisan21 avatar

Stargazers

Syam Nath avatar MapleTree avatar Hannah Clayton avatar Scott Veirs avatar Denise Risch avatar  avatar Neha Ram avatar Jamie Mac avatar

Watchers

James Cloos avatar  avatar Jamie Mac avatar Denise Risch avatar

pambinaries's Issues

Add deep learning detections

PAMGuard has a new deep learning module which outputs both a new type of detection (a deep learning detection) and adds deep learning annotations to existing data units. There are examples of the functions in MATLAB PAMGuard library (readDLAnnotation.m and readDLDetData.m). Could these also be implemented in R?

See here for more info on the PAMGuard deep learning module and example of how to use the MATLAB code.

whistle & moan detector: get each tonal start time in seconds from beginning of read audio file.

Hello. I ran pamguard on one of the audio files on mobysound.org. I also configured it to save the results to a binary file, which I'm reading with PamBinaries. For the output of loadPamguardBinaryFile, how does the startSample field relate to the number of seconds from the start of the audio file? Is it startSample / sampleRate = time offset in seconds? I'm looking to get the detected whistle's starting time in seconds from the start of the audio file.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.