Created
September 18, 2015 08:20
-
-
Save rob-luke/224e7c4376085aa6f56b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"# Rename Raw EEG Recordings" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"By default the raw EEG files have file names like `15.07.28-19.36.49-biosemiassr-P2.bdf` that are not informative.\n", | |
"Rename the files to include the participant name and condition `P2-40Hz-L-2.bdf`." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 5, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [], | |
"source": [ | |
"using EEG\n", | |
"using Logging\n", | |
"using ProgressMeter\n", | |
"Logging.configure(level=WARNING);" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 6, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [], | |
"source": [ | |
"searchdir(path,key) = filter(x->contains(x,key), readdir(path))\n", | |
"cd(\"/workspace/Data/EEG/fEEG/BDFs/New/\")\n", | |
"mkdir(\"Renamed-Files\");" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 7, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"Computing...100% Time: 0:10:05\n" | |
] | |
} | |
], | |
"source": [ | |
"@showprogress 1 \"Computing...\" for filename in searchdir(\".\", \".bdf\")\n", | |
" \n", | |
" # Read in the raw data and reduce number of channels\n", | |
" a = read_SSR(filename, min_epoch_length=8380, max_epoch_length=8395)\n", | |
" \n", | |
" # New file name\n", | |
" fname = \"Renamed-Files/$(replace(a.header[\"subjID\"], \" \", \"\"))-$(a.header[\"rbadata\"][\"properties\"][\"metas\"][\"summary\"]).bdf\" \n", | |
" fname = replace(fname, \"00\", \"00Hz\")\n", | |
" fname = replace(fname, \"40\", \"40Hz\")\n", | |
" fname = replace(fname, \"80\", \"80Hz\")\n", | |
" \n", | |
" # Write file to disk with new name\n", | |
" write_SSR(a, fname)\n", | |
" \n", | |
" # Copy the mat file and rename it too\n", | |
" cp(string(filename[1:end-4], \"-properties.mat\"), string(fname[1:end-4], \".mat\"))\n", | |
"end" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": { | |
"collapsed": true | |
}, | |
"outputs": [], | |
"source": [] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Julia 0.3.11", | |
"language": "julia", | |
"name": "julia-0.3" | |
}, | |
"language_info": { | |
"name": "julia", | |
"version": "0.3.11" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 0 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment