Skip to content

Instantly share code, notes, and snippets.

@erzk
erzk / loading_and_plotting_nirs_data.Rmd
Created Dec 18, 2016
RMarkdown file showing the nirs data analysis
View loading_and_plotting_nirs_data.Rmd
---
title: "Loading and plotting nirs data"
author: "Eryk Walczak"
date: "18 December 2016"
output:
html_document: default
pdf_document: default
---
```{r setup, include=FALSE}
@erzk
erzk / geofacet_grid_Poland.R
Last active Jul 21, 2019
geofacet - siatka z województwami
View geofacet_grid_Poland.R
# geofacet - Polska
# Ludność w miastach w % ogółu ludności (dane roczne)
library(dplyr)
library(geofacet)
library(ggplot2)
library(readxl)
# dane z Banku Danych Lokalnych
# https://bdl.stat.gov.pl/BDL/dane/podgrup/tablica
@erzk
erzk / fNIRS_experiment_alpha.py
Last active Jun 21, 2019
First version of the fNIRS experiment using the serial port (A triggers - blocks, B triggers - stimuli)
View fNIRS_experiment_alpha.py
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
This experiment was created using PsychoPy2 Experiment Builder (v1.83.04), February 07, 2017, at 16:33
If you publish work using this script please cite the relevant PsychoPy publications
Peirce, JW (2007) PsychoPy - Psychophysics software in Python. Journal of Neuroscience Methods, 162(1-2), 8-13.
Peirce, JW (2009) Generating stimuli for neuroscience using PsychoPy. Frontiers in Neuroinformatics, 2:10. doi: 10.3389/neuro.11.010.2008
"""
from __future__ import division # so that 1/3=0.333 instead of 1/3=0
@erzk
erzk / split_continuous_audio.py
Created Feb 24, 2019
Split continuous audio files on occurrence of silence
View split_continuous_audio.py
#!/usr/bin/env python
import glob, os
for file in sorted(glob.glob("*.wav")):
print("#"*40)
print(file)
os.system("python audioAnalysis.py silenceRemoval -i " + file + " --smoothing 0.2 --weight 0.1")
@erzk
erzk / praat_pitch_analysis.R
Created Feb 11, 2019
Extract pitch values, intensity, time, and confidence from Praat pitch files
View praat_pitch_analysis.R
#!/usr/bin/env r
## load pitch files extracted from Praat and pull key information
# take input from the command line
f <- argv
# load packages and hide messages
library(dplyr)
library(rPraat)
@erzk
erzk / extract_pitch_script.praat
Created Feb 10, 2019
Extract pitch values, intensity, time, and confidence from all wav files in the working directory
View extract_pitch_script.praat
clearinfo
# uncomment for a point-and-click version (then the next two lines should be commented out)
#inDir$ = chooseDirectory$: "Choose the folder containing your wav files"
wd$ = "./"
inDir$ = wd$
# create a list of all wav files in the chosen directory
inDirWild$ = inDir$ + "*.wav"
View hht_spectrogram.R
library(hht)
data(PortFosterEvent)
dt <- mean(diff(tt))
ft <- list()
ft$nfft <- 4096
ft$ns <- 30
ft$nov <- 29
View standalone_spectrogram.R
library(RCurl)
# download the R code
script <- getURL("https://raw.githubusercontent.com/usagi5886/dsp/master/Spectrogram().r",
ssl.verifypeer = FALSE)
# load it as a function
eval(parse(text = script))
library(audio)
# download the wav file
View warbleR_spectrogram.R
library(warbleR)
# load and save data
data(list = c("Phae.long1", "Phae.long2","selec.table"))
writeWave(Phae.long1, "Phae.long1.wav")
# make spectrograms (saves the files in the working directory)
specreator(X = selec.table, flim = c(0, 11), res = 300, mar = 0.05, wl = 300)
View soundgen_spectrogram.R
library(soundgen)
# synthesize a sound 1 s long, with gradually increasing hissing noise
sound = soundgen(sylLen = 1000,
temperature = 0.001,
noiseAnchors = list(
time = c(0, 1300),
value = c(-120, 0)),
formantsNoise = list(
f1 = list(