├── .gitattributes ├── .gitignore ├── 18subplots_onbe.fig ├── AnalyzingNeuralTimeSeriesData ├── Cohen_AnalyzingNeuralTimeSeriesData_TOC.pdf └── code │ ├── accumbens_eeg.mat │ ├── amsterdam.bmp │ ├── armorf.m │ ├── chapter02.m │ ├── chapter04_datafile.txt │ ├── chapter04_excel_data.xls │ ├── chapter04_headache_data.txt │ ├── chapter04a.m │ ├── chapter04b.m │ ├── chapter04c.m │ ├── chapter05.m │ ├── chapter06.m │ ├── chapter09.m │ ├── chapter10.m │ ├── chapter11.m │ ├── chapter12.m │ ├── chapter13.m │ ├── chapter14.m │ ├── chapter15.m │ ├── chapter16.m │ ├── chapter17.m │ ├── chapter18.m │ ├── chapter19.m │ ├── chapter20.m │ ├── chapter22.m │ ├── chapter23.m │ ├── chapter25.m │ ├── chapter26.m │ ├── chapter27.m │ ├── chapter28.m │ ├── chapter29.m │ ├── chapter30.m │ ├── chapter31.m │ ├── chapter33.m │ ├── chapter34.m │ ├── cover_art.m │ ├── data2psiX.m │ ├── data_output_SPSS_format.txt │ ├── data_written_from_matlab.txt │ ├── emdx.m │ ├── entropyx.m │ ├── erpviewerx.fig │ ├── erpviewerx.m │ ├── fdr.m │ ├── figure34_3_data.mat │ ├── frequency_sliding_and_median_filter.m │ ├── interpolate_nola.m │ ├── interpolate_perrinX.m │ ├── laplacian_nola.m │ ├── laplacian_perrinX.m │ ├── mutualinformationx.m │ ├── my_matlab_variables.mat │ ├── pathlength.m │ ├── sampleEEGdata.mat │ ├── solutions2exercises.pdf │ ├── tfviewerx.fig │ └── tfviewerx.m ├── BenchmarkingSpikeSortingPrograms.m ├── CellArrayOfStruct2Table.m ├── ElecCoord.m ├── ExtractChunks.m ├── FR_Histo.m ├── FigViewer ├── FigViewer.exe ├── FigViewer.m ├── FigViewer.prj ├── FigViewer │ ├── PackagingLog.html │ ├── for_redistribution │ │ └── MyAppInstaller_web.exe │ ├── for_redistribution_files_only │ │ ├── FigViewer.exe │ │ ├── readme.txt │ │ └── splash.png │ └── for_testing │ │ ├── FigViewer.exe │ │ ├── mccExcludedFiles.log │ │ ├── readme.txt │ │ ├── requiredMCRProducts.txt │ │ └── splash.png ├── mccExcludedFiles.log ├── readme.txt └── requiredMCRProducts.txt ├── Gdatatheor ├── README ├── buttfilt.m ├── countprob.m ├── dispersion.m ├── fithifref.m ├── fithlifref.m ├── gaussroc.m ├── gfitheor.m ├── gpstheor.m ├── isidist.m ├── lgnfilt.m ├── neymtacnt.m ├── poisscnt.m ├── prefdisp.m ├── psautospk.m ├── psautostim.m ├── roc.m ├── sndpdisp.m ├── stesttheor.m ├── stimest.m └── wiener1.m ├── GenNoisySig.m ├── ImportJRClusSortInfo.m ├── InhCumWeib.m ├── JaccardTest.m ├── MahalClusDist.m ├── MakeASCII4.m ├── Matlab2Goog ├── Matlab2GoogTest.m ├── README.txt ├── changeWorksheetNameAndSize.m ├── connectNAuthorize.m ├── createSpreadsheet.m ├── createWorksheet.m ├── deleteSpreadsheet.m ├── deleteWorksheet.m ├── editWorksheetCell.m ├── getSpreadsheetList.m ├── getSpreadsheetListGDocs.m ├── getWorksheetCell.m ├── getWorksheetList.m ├── license.txt └── urlreadwrite.m ├── PopClusteringAuto_Manual.m ├── Raster_sdf_colorevents.m ├── Read_ArduSerial.m ├── Read_ArduSerial_old.m ├── ResamplingStats ├── SchieberLabResamplingStats │ ├── eg18_014.txt │ ├── h14.m │ ├── h15.m │ ├── randomize_matrix.m │ ├── randperm2.m │ └── randsample.m ├── correlation.m ├── nonansem.m ├── nonanstd.m ├── resampling_statistical_toolkit │ ├── __MACOSX │ │ └── statistics │ │ │ ├── ._README.txt │ │ │ └── ._statcond.m │ ├── license.txt │ └── statistics │ │ ├── .svn │ │ ├── all-wcprops │ │ ├── entries │ │ └── text-base │ │ │ ├── README.txt.svn-base │ │ │ ├── anova1_cell.m.svn-base │ │ │ ├── anova1rm_cell.m.svn-base │ │ │ ├── anova2_cell.m.svn-base │ │ │ ├── anova2rm_cell.m.svn-base │ │ │ ├── concatdata.m.svn-base │ │ │ ├── corrcoef_cell.m.svn-base │ │ │ ├── fdr.m.svn-base │ │ │ ├── statcond.m.svn-base │ │ │ ├── teststat.m.svn-base │ │ │ ├── ttest2_cell.m.svn-base │ │ │ └── ttest_cell.m.svn-base │ │ ├── README.txt │ │ ├── anova1_cell.m │ │ ├── anova1rm_cell.m │ │ ├── anova2_cell.m │ │ ├── anova2rm_cell.m │ │ ├── concatdata.m │ │ ├── corrcoef_cell.m │ │ ├── fdr.m │ │ ├── stat_surrogate_ci.m │ │ ├── stat_surrogate_pvals.m │ │ ├── statcond.m │ │ ├── statcondfieldtrip.m │ │ ├── surrogdistrib.m │ │ ├── teststat.m │ │ ├── ttest2_cell.m │ │ └── ttest_cell.m └── shuffle.m ├── SEM_calc.m ├── SFC.m ├── SHdaq2csv.m ├── SHdaq2mat.m ├── SelectElipse.m ├── ShuffledClassification.m ├── Spk2txt.m ├── UserDirInfo.m ├── adinstruments_sdk_matlab ├── +adi │ ├── +examples │ │ ├── conversion_speed_testing.m │ │ ├── e001_writeFileFromScratch.m │ │ └── e002_addCommentsToAnExistingFile.m │ ├── +postp │ │ └── mergeComments.m │ ├── +sdk │ │ └── ReadMe.md │ ├── +sl │ │ ├── +array │ │ │ └── uniqueWithGroupIndices.m │ │ ├── +cellstr │ │ │ └── join.m │ │ ├── +datetime │ │ │ ├── getTimeZone.m │ │ │ └── unixToMatlab.m │ │ ├── +dir │ │ │ ├── changeFileExtension.m │ │ │ └── filepartsx.m │ │ ├── +in │ │ │ ├── processVarargin.m │ │ │ └── process_varargin_result.m │ │ ├── +stack │ │ │ ├── calling_function_info.m │ │ │ ├── getMyBasePath.m │ │ │ └── getPackageRoot.m │ │ └── +str │ │ │ └── contains.m │ ├── +tests │ │ └── t001_speedWritingAndWriting.m │ ├── @channel │ │ ├── channel.m │ │ └── exportToHDF5File.m │ ├── @file_viewer │ │ ├── file_viewer.m │ │ └── private │ │ │ └── main.fig │ ├── binary_channel_writer.m │ ├── binary_file_writer.m │ ├── channel_writer.m │ ├── comment.m │ ├── comment_handle.m │ ├── convert.m │ ├── createFile.m │ ├── data_writer_handle.m │ ├── documentation │ │ ├── FunctionMapping.csv │ │ └── com_interface_notes.m │ ├── editFile.m │ ├── extractRecordToNewFile.m │ ├── file.m │ ├── file_handle.m │ ├── file_read_options.m │ ├── file_writer.m │ ├── h5_conversion_options.m │ ├── h5_file_h.m │ ├── h5_file_sdk.m │ ├── handle_logger.m │ ├── handle_manager.m │ ├── mat_comment_handle.m │ ├── mat_conversion_options.m │ ├── mat_file_h.m │ ├── mat_file_sdk.m │ ├── private │ │ ├── ADIDatCAPI_mex.h │ │ ├── c.m │ │ ├── c0.m │ │ ├── clong.m │ │ ├── sdk_mex.cpp │ │ ├── sdk_mex.mexw32 │ │ └── sdk_mex.mexw64 │ ├── readFile.m │ ├── record.m │ ├── sdk.m │ └── test_SDK.m ├── .gitignore ├── LICENSE ├── README.rst ├── adi.m ├── documentation │ ├── ReadMe.md │ └── organization.md └── files │ ├── LabChartBinaryFormat.pdf │ ├── blank_labchart_8_file.adicht │ └── crash_testing.m ├── adtest2.m ├── aes ├── AES_GET_COUNTER.m ├── Contents.m ├── Readme.m ├── aes.m ├── aesdecrypt.m ├── aesencrypt.m ├── aesinfo.m ├── aesinit.m └── aestest.m ├── alpha_filtconv.m ├── anova_rm.m ├── applyhatch_plusC.m ├── batch ├── ConvertTIFFtoAVI.bat ├── convert_tiff_to_avi.py └── readme.md ├── catamaran_spike_sorting ├── catamaran.m ├── catamaran_doc.pdf ├── nttfile.m └── readme.txt ├── catstruct.m ├── clustering ├── calcAUROC.m ├── clus_pop_ROC.m ├── clusterROC.m └── simpleROC.m ├── compare_clustering.m ├── compare_db_filelist.m ├── compare_db_filelists.m ├── convolve2.m ├── crosscorel.m ├── demo_fiola_pipeline_new.ipynb ├── demo_pipeline_voltage_imaging.ipynb ├── density_estimation-master ├── .gitignore ├── README.md ├── matlab │ ├── sshist.m │ ├── sskernel.m │ ├── ssvkernel.m │ └── tutorial.m ├── python │ └── sskernel.py └── ref │ ├── shimazaki_jcns10.pdf │ └── shimazaki_neco07.pdf ├── disprecdepth.m ├── doseResponse.m ├── dyncirc.m ├── eighteensubplots_onbe.m ├── eventraststats.m ├── exindex.m ├── fconvert.m ├── findauc.m ├── fread_workingresize.m ├── gapstopdebug.m ├── gauss_filtconv.m ├── gaussfilt.m ├── gen_nonhomoPoissonProc.m ├── getdir_fpos.m ├── graphic_interface_toolkit ├── __MACOSX │ └── guifunc │ │ ├── ._README.txt │ │ └── ._inputgui.m ├── guifunc │ ├── .svn │ │ ├── all-wcprops │ │ ├── entries │ │ └── text-base │ │ │ ├── errordlg2.m.svn-base │ │ │ ├── finputcheck.m.svn-base │ │ │ ├── inputdlg2.m.svn-base │ │ │ ├── inputgui.m.svn-base │ │ │ ├── listdlg2.m.svn-base │ │ │ ├── pophelp.m.svn-base │ │ │ ├── questdlg2.m.svn-base │ │ │ ├── supergui.m.svn-base │ │ │ └── warndlg2.m.svn-base │ ├── README.txt │ ├── errordlg2.m │ ├── finputcheck.m │ ├── inputdlg2.m │ ├── inputgui.m │ ├── listdlg2.m │ ├── pophelp.m │ ├── questdlg2.m │ ├── supergui.m │ └── warndlg2.m └── license.txt ├── h5create_Ephys.m ├── instantfr.m ├── latency_analysis.m ├── linspecer ├── license.txt └── linspecer.m ├── listresortfiles.m ├── m2vbColor.m ├── make_movie_from_signal.m ├── mcnemar.m ├── min_max_values.m ├── my_cc_circ_shift.m ├── mysql ├── mysql.cpp └── mysql.m ├── nanconv.m ├── nonhomopp.m ├── nonparam_ttest_comp.m ├── open_dicom.m ├── openreadclose.m ├── periodCmdplot.m ├── plot2svg ├── README.md ├── example │ ├── demo_3d_plot2svg.m │ ├── demo_svg_water.m │ ├── gradient.png │ ├── matterhorn_small.jpg │ ├── output │ │ ├── demo_svg_water.jpg │ │ ├── demo_svg_water.svg │ │ ├── sphere.png │ │ ├── sphere.svg │ │ ├── sphere.svgz │ │ ├── temperature_nicer.svg │ │ ├── temperature_perfect.jpg │ │ ├── temperature_perfect.svg │ │ ├── temperature_standard.svg │ │ ├── tutorial_filters.jpg │ │ └── tutorial_filters.svg │ ├── tutorial_filters.m │ ├── tutorial_plot2svg.m │ └── water_stones.jpg ├── license.txt └── src │ ├── plot2svg.m │ ├── simulink2svg.m │ ├── svgBoundingBox.m │ ├── svgComposite.m │ ├── svgGaussianBlur.m │ ├── svgImage.m │ ├── svgLuminanceToAlpha.m │ ├── svgOffset.m │ ├── svgSpecularLightingDistant.m │ └── svgTurbulence.m ├── plot_JRClust_waveform_export.m ├── ploteyesac.m ├── poissonTutorial.m ├── rasterstattest.m ├── rastplotstat.m ├── raststats.m ├── read_and_make_movie.m ├── read_videoframes.m ├── readxlsrownum.m ├── rec_plot.m ├── regexpisymbols.m ├── shifter.m ├── siglag.m ├── sigmoidfit.m ├── sshfrommatlab_13b ├── ganymed-ssh2-build250 │ ├── HISTORY.txt │ ├── LICENSE.txt │ ├── README.txt │ ├── examples │ │ ├── Basic.java │ │ ├── BasicWithHTTPProxy.java │ │ ├── PortForwarding.java │ │ ├── PublicKeyAuthentication.java │ │ ├── SimpleVerifier.java │ │ ├── SingleThreadStdoutStderr.java │ │ ├── StdoutAndStderr.java │ │ ├── SwingShell.java │ │ └── UsingKnownHosts.java │ ├── faq │ │ └── FAQ.html │ ├── ganymed-ssh2-build250.jar │ ├── javadoc │ │ ├── allclasses-frame.html │ │ ├── allclasses-noframe.html │ │ ├── ch │ │ │ └── ethz │ │ │ │ └── ssh2 │ │ │ │ ├── ChannelCondition.html │ │ │ │ ├── Connection.html │ │ │ │ ├── ConnectionInfo.html │ │ │ │ ├── ConnectionMonitor.html │ │ │ │ ├── DHGexParameters.html │ │ │ │ ├── HTTPProxyData.html │ │ │ │ ├── HTTPProxyException.html │ │ │ │ ├── InteractiveCallback.html │ │ │ │ ├── KnownHosts.html │ │ │ │ ├── LocalPortForwarder.html │ │ │ │ ├── LocalStreamForwarder.html │ │ │ │ ├── ProxyData.html │ │ │ │ ├── SCPClient.html │ │ │ │ ├── SFTPException.html │ │ │ │ ├── SFTPv3Client.html │ │ │ │ ├── SFTPv3DirectoryEntry.html │ │ │ │ ├── SFTPv3FileAttributes.html │ │ │ │ ├── SFTPv3FileHandle.html │ │ │ │ ├── ServerHostKeyVerifier.html │ │ │ │ ├── Session.html │ │ │ │ ├── StreamGobbler.html │ │ │ │ ├── class-use │ │ │ │ ├── ChannelCondition.html │ │ │ │ ├── Connection.html │ │ │ │ ├── ConnectionInfo.html │ │ │ │ ├── ConnectionMonitor.html │ │ │ │ ├── DHGexParameters.html │ │ │ │ ├── HTTPProxyData.html │ │ │ │ ├── HTTPProxyException.html │ │ │ │ ├── InteractiveCallback.html │ │ │ │ ├── KnownHosts.html │ │ │ │ ├── LocalPortForwarder.html │ │ │ │ ├── LocalStreamForwarder.html │ │ │ │ ├── ProxyData.html │ │ │ │ ├── SCPClient.html │ │ │ │ ├── SFTPException.html │ │ │ │ ├── SFTPv3Client.html │ │ │ │ ├── SFTPv3DirectoryEntry.html │ │ │ │ ├── SFTPv3FileAttributes.html │ │ │ │ ├── SFTPv3FileHandle.html │ │ │ │ ├── ServerHostKeyVerifier.html │ │ │ │ ├── Session.html │ │ │ │ └── StreamGobbler.html │ │ │ │ ├── package-frame.html │ │ │ │ ├── package-summary.html │ │ │ │ ├── package-tree.html │ │ │ │ └── package-use.html │ │ ├── constant-values.html │ │ ├── deprecated-list.html │ │ ├── help-doc.html │ │ ├── index-all.html │ │ ├── index.html │ │ ├── overview-summary.html │ │ ├── overview-tree.html │ │ ├── package-list │ │ ├── resources │ │ │ └── inherit.gif │ │ ├── serialized-form.html │ │ └── stylesheet.css │ └── src │ │ └── ch │ │ └── ethz │ │ └── ssh2 │ │ ├── ChannelCondition.java │ │ ├── Connection.java │ │ ├── ConnectionInfo.java │ │ ├── ConnectionMonitor.java │ │ ├── DHGexParameters.java │ │ ├── HTTPProxyData.java │ │ ├── HTTPProxyException.java │ │ ├── InteractiveCallback.java │ │ ├── KnownHosts.java │ │ ├── LocalPortForwarder.java │ │ ├── LocalStreamForwarder.java │ │ ├── ProxyData.java │ │ ├── SCPClient.java │ │ ├── SFTPException.java │ │ ├── SFTPv3Client.java │ │ ├── SFTPv3DirectoryEntry.java │ │ ├── SFTPv3FileAttributes.java │ │ ├── SFTPv3FileHandle.java │ │ ├── ServerHostKeyVerifier.java │ │ ├── Session.java │ │ ├── StreamGobbler.java │ │ ├── auth │ │ └── AuthenticationManager.java │ │ ├── channel │ │ ├── Channel.java │ │ ├── ChannelInputStream.java │ │ ├── ChannelManager.java │ │ ├── ChannelOutputStream.java │ │ ├── IChannelWorkerThread.java │ │ ├── LocalAcceptThread.java │ │ ├── RemoteAcceptThread.java │ │ ├── RemoteForwardingData.java │ │ ├── RemoteX11AcceptThread.java │ │ ├── StreamForwarder.java │ │ └── X11ServerData.java │ │ ├── crypto │ │ ├── Base64.java │ │ ├── CryptoWishList.java │ │ ├── KeyMaterial.java │ │ ├── PEMDecoder.java │ │ ├── PEMStructure.java │ │ ├── SimpleDERReader.java │ │ ├── cipher │ │ │ ├── AES.java │ │ │ ├── BlockCipher.java │ │ │ ├── BlockCipherFactory.java │ │ │ ├── BlowFish.java │ │ │ ├── CBCMode.java │ │ │ ├── CTRMode.java │ │ │ ├── CipherInputStream.java │ │ │ ├── CipherOutputStream.java │ │ │ ├── DES.java │ │ │ ├── DESede.java │ │ │ └── NullCipher.java │ │ ├── dh │ │ │ ├── DhExchange.java │ │ │ └── DhGroupExchange.java │ │ └── digest │ │ │ ├── Digest.java │ │ │ ├── HMAC.java │ │ │ ├── HashForSSH2Types.java │ │ │ ├── MAC.java │ │ │ ├── MD5.java │ │ │ └── SHA1.java │ │ ├── log │ │ └── Logger.java │ │ ├── packets │ │ ├── PacketChannelOpenConfirmation.java │ │ ├── PacketChannelOpenFailure.java │ │ ├── PacketChannelWindowAdjust.java │ │ ├── PacketDisconnect.java │ │ ├── PacketGlobalCancelForwardRequest.java │ │ ├── PacketGlobalForwardRequest.java │ │ ├── PacketIgnore.java │ │ ├── PacketKexDHInit.java │ │ ├── PacketKexDHReply.java │ │ ├── PacketKexDhGexGroup.java │ │ ├── PacketKexDhGexInit.java │ │ ├── PacketKexDhGexReply.java │ │ ├── PacketKexDhGexRequest.java │ │ ├── PacketKexDhGexRequestOld.java │ │ ├── PacketKexInit.java │ │ ├── PacketNewKeys.java │ │ ├── PacketOpenDirectTCPIPChannel.java │ │ ├── PacketOpenSessionChannel.java │ │ ├── PacketServiceAccept.java │ │ ├── PacketServiceRequest.java │ │ ├── PacketSessionExecCommand.java │ │ ├── PacketSessionPtyRequest.java │ │ ├── PacketSessionStartShell.java │ │ ├── PacketSessionSubsystemRequest.java │ │ ├── PacketSessionX11Request.java │ │ ├── PacketUserauthBanner.java │ │ ├── PacketUserauthFailure.java │ │ ├── PacketUserauthInfoRequest.java │ │ ├── PacketUserauthInfoResponse.java │ │ ├── PacketUserauthRequestInteractive.java │ │ ├── PacketUserauthRequestNone.java │ │ ├── PacketUserauthRequestPassword.java │ │ ├── PacketUserauthRequestPublicKey.java │ │ ├── Packets.java │ │ ├── TypesReader.java │ │ └── TypesWriter.java │ │ ├── sftp │ │ ├── AttrTextHints.java │ │ ├── AttribBits.java │ │ ├── AttribFlags.java │ │ ├── AttribPermissions.java │ │ ├── AttribTypes.java │ │ ├── ErrorCodes.java │ │ ├── OpenFlags.java │ │ └── Packet.java │ │ ├── signature │ │ ├── DSAPrivateKey.java │ │ ├── DSAPublicKey.java │ │ ├── DSASHA1Verify.java │ │ ├── DSASignature.java │ │ ├── RSAPrivateKey.java │ │ ├── RSAPublicKey.java │ │ ├── RSASHA1Verify.java │ │ └── RSASignature.java │ │ ├── transport │ │ ├── ClientServerHello.java │ │ ├── KexManager.java │ │ ├── KexParameters.java │ │ ├── KexState.java │ │ ├── MessageHandler.java │ │ ├── NegotiateException.java │ │ ├── NegotiatedParameters.java │ │ ├── TransportConnection.java │ │ └── TransportManager.java │ │ └── util │ │ ├── StringEncoder.java │ │ ├── TimeoutService.java │ │ └── Tokenizer.java ├── license.txt ├── scptomatlab.m ├── sftpfrommatlab.m ├── sshfrommatlab.m ├── sshfrommatlab_publickey.m ├── sshfrommatlab_publickey_file.m ├── sshfrommatlabclose.m ├── sshfrommatlabinstall.m ├── sshfrommatlabissue.m └── sshfrommatlabissue_dontwait.m ├── storeDataFromSerial.m ├── tachCM2.m ├── template_curve_match.m └── tuckermcclure-matlab-plot-big-00aea55 ├── .gitignore ├── LICENSE ├── LinePlotExplorer.m ├── LinePlotReducer.m ├── README.md ├── examples_of_line_plot_reducer.m ├── get_axes_width.m ├── reduce_plot.m ├── reduce_to_width.m └── screenshot.png /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | *.sln merge=union 7 | *.csproj merge=union 8 | *.vbproj merge=union 9 | *.fsproj merge=union 10 | *.dbproj merge=union 11 | 12 | # Standard to msysgit 13 | *.doc diff=astextplain 14 | *.DOC diff=astextplain 15 | *.docx diff=astextplain 16 | *.DOCX diff=astextplain 17 | *.dot diff=astextplain 18 | *.DOT diff=astextplain 19 | *.pdf diff=astextplain 20 | *.PDF diff=astextplain 21 | *.rtf diff=astextplain 22 | *.RTF diff=astextplain 23 | -------------------------------------------------------------------------------- /18subplots_onbe.fig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vncntprvst/tools/d4c6e382d9de4dfe6e26ba2a34b5f170635f0c7b/18subplots_onbe.fig -------------------------------------------------------------------------------- /AnalyzingNeuralTimeSeriesData/Cohen_AnalyzingNeuralTimeSeriesData_TOC.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vncntprvst/tools/d4c6e382d9de4dfe6e26ba2a34b5f170635f0c7b/AnalyzingNeuralTimeSeriesData/Cohen_AnalyzingNeuralTimeSeriesData_TOC.pdf -------------------------------------------------------------------------------- /AnalyzingNeuralTimeSeriesData/code/accumbens_eeg.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vncntprvst/tools/d4c6e382d9de4dfe6e26ba2a34b5f170635f0c7b/AnalyzingNeuralTimeSeriesData/code/accumbens_eeg.mat -------------------------------------------------------------------------------- /AnalyzingNeuralTimeSeriesData/code/amsterdam.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vncntprvst/tools/d4c6e382d9de4dfe6e26ba2a34b5f170635f0c7b/AnalyzingNeuralTimeSeriesData/code/amsterdam.bmp -------------------------------------------------------------------------------- /AnalyzingNeuralTimeSeriesData/code/chapter04_datafile.txt: -------------------------------------------------------------------------------- 1 | 1 2 3 2 | 4 5 6 3 | 7 8 9 4 | -------------------------------------------------------------------------------- /AnalyzingNeuralTimeSeriesData/code/chapter04_excel_data.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vncntprvst/tools/d4c6e382d9de4dfe6e26ba2a34b5f170635f0c7b/AnalyzingNeuralTimeSeriesData/code/chapter04_excel_data.xls -------------------------------------------------------------------------------- /AnalyzingNeuralTimeSeriesData/code/chapter04_headache_data.txt: -------------------------------------------------------------------------------- 1 | this is a text file with mixed strings and numbers. 2 | each row contains different information, some useful and some useless. 3 | we'll use matlab to read in each line separately, figure 4 | out whether to keep or trash that line, and extract the data we want. 5 | 6 | in this file, label-value data pairs are separated by tabs. it's the one 7 | useful thing we have to go on here. 8 | 9 | 10 | behavioral data begin on the following line 11 | trial 1 choice 2 rt 450 accuracy 1 12 | choice 2 trial 2 accuracy 0 rt 830 13 | well, i could go on and on, but by this time you'll get the idea -------------------------------------------------------------------------------- /AnalyzingNeuralTimeSeriesData/code/chapter06.m: -------------------------------------------------------------------------------- 1 | %% Analyzing Neural Time Series Data 2 | % Matlab code for Chapter 6 3 | % Mike X Cohen 4 | % 5 | % This code accompanies the book, titled "Analyzing Neural Time Series Data" 6 | % (MIT Press). Using the code without following the book may lead to confusion, 7 | % incorrect data analyses, and misinterpretations of results. 8 | % Mike X Cohen assumes no responsibility for inappropriate or incorrect use of this code. 9 | 10 | %% Figure 6.2 11 | 12 | % create sine wave 13 | srate = 1000; 14 | time = 0:1/srate:1; 15 | frequency = 3; 16 | 17 | sinewave = sin(2*pi*frequency.*time); 18 | 19 | figure 20 | subplot(311) 21 | plot(time,sinewave,'r') 22 | set(gca,'xlim',[-.05 time(end)*1.05],'ylim',[-1.1 1.1]) 23 | hold on 24 | sampling1 = round(linspace(1,length(time),frequency*2)); 25 | plot(time(sampling1),sinewave(sampling1),'o') 26 | title('continuous sine wave') 27 | 28 | sampling2 = round(linspace(1,length(time),frequency*20)); 29 | plot(time(sampling2),sinewave(sampling2),'+') 30 | 31 | 32 | subplot(312) 33 | plot(time(sampling1),sinewave(sampling1),'-o') 34 | set(gca,'xlim',[-.05 time(end)*1.05],'ylim',[-1.1 1.1]) 35 | title('sampled at 2*frequency') 36 | 37 | subplot(313) 38 | plot(time(sampling2),sinewave(sampling2),'-+') 39 | title('sampled at 20*frequency') 40 | set(gca,'xlim',[-.05 time(end)*1.05],'ylim',[-1.1 1.1]) 41 | 42 | %% end. 43 | -------------------------------------------------------------------------------- /AnalyzingNeuralTimeSeriesData/code/data_output_SPSS_format.txt: -------------------------------------------------------------------------------- 1 | Name trial choice rt accuracy 2 | billy 1 2 450 1 3 | bob 2 2 830 0 4 | -------------------------------------------------------------------------------- /AnalyzingNeuralTimeSeriesData/code/data_written_from_matlab.txt: -------------------------------------------------------------------------------- 1 | 1 2 3 2 | 4 5 6 3 | 7 8 9 4 | -------------------------------------------------------------------------------- /AnalyzingNeuralTimeSeriesData/code/entropyx.m: -------------------------------------------------------------------------------- 1 | function [entropy fd_bins] = entropyx(x,fd_bins) 2 | % ENTROPYX Compute entropy 3 | % 4 | % Inputs: 5 | % x : data matrix 6 | % 7 | % Optional inputs: 8 | % bins : number of bins to use for distribution discretization 9 | % 10 | % Outputs: 11 | % entropy : entropy of x, y, and joint 12 | % nbins : number of bins used for discretization 13 | % (based on Freedman-Diaconis rule) 14 | % 15 | % Mike X Cohen (mikexcohen@gmail.com) 16 | 17 | %% determine the optimal number of bins for each variable 18 | 19 | % vectorize in the case of matrices 20 | x=x(:); 21 | 22 | if nargin<2 || isempty(fd_bins) 23 | n = length(x); 24 | maxmin_range = max(x)-min(x); 25 | fd_bins = ceil(maxmin_range/(2.0*iqr(x)*n^(-1/3))); % Freedman-Diaconis 26 | end 27 | 28 | %% bin data 29 | 30 | edges = linspace(min(x),max(x),fd_bins+1); 31 | [nPerBin1,bins1] = histc(x,edges); 32 | 33 | %% compute entropies 34 | 35 | % recompute entropy with optimal bins for comparison 36 | hdat1 = hist(x,fd_bins); 37 | hdat1 = hdat1./sum(hdat1); 38 | 39 | % convert histograms to probability values 40 | entropy = -sum(hdat1.*log2(hdat1+eps)); 41 | 42 | %% 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /AnalyzingNeuralTimeSeriesData/code/erpviewerx.fig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vncntprvst/tools/d4c6e382d9de4dfe6e26ba2a34b5f170635f0c7b/AnalyzingNeuralTimeSeriesData/code/erpviewerx.fig -------------------------------------------------------------------------------- /AnalyzingNeuralTimeSeriesData/code/fdr.m: -------------------------------------------------------------------------------- 1 | function [pID,pN] = fdr(p,q) 2 | % FORMAT [pID,pN] = fdr(p,q) 3 | % 4 | % p - vector of p-values 5 | % q - False Discovery Rate level 6 | % 7 | % pID - p-value threshold based on independence or positive dependence 8 | % pN - Nonparametric p-value threshold 9 | %______________________________________________________________________________ 10 | % $Id: FDR.m,v 1.1 2009/10/20 09:04:30 nichols Exp $ 11 | 12 | 13 | p = p(isfinite(p)); % Toss NaN's 14 | p = sort(p(:)); 15 | V = length(p); 16 | I = (1:V)'; 17 | 18 | cVID = 1; 19 | cVN = sum(1./(1:V)); 20 | 21 | pID = p(find(p<=I/V*q/cVID,1,'last' )); 22 | pN = p(find(p<=I/V*q/cVN, 1,'last' )); 23 | -------------------------------------------------------------------------------- /AnalyzingNeuralTimeSeriesData/code/figure34_3_data.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vncntprvst/tools/d4c6e382d9de4dfe6e26ba2a34b5f170635f0c7b/AnalyzingNeuralTimeSeriesData/code/figure34_3_data.mat -------------------------------------------------------------------------------- /AnalyzingNeuralTimeSeriesData/code/my_matlab_variables.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vncntprvst/tools/d4c6e382d9de4dfe6e26ba2a34b5f170635f0c7b/AnalyzingNeuralTimeSeriesData/code/my_matlab_variables.mat -------------------------------------------------------------------------------- /AnalyzingNeuralTimeSeriesData/code/pathlength.m: -------------------------------------------------------------------------------- 1 | function Plength = pathlength(A) 2 | 3 | % PATHLENGTH Calculate minimum pathlengths for a given adjacency 4 | % matrix. 5 | % 6 | % Input A: n by n adjacency matrix (symmetric). 7 | % 8 | % Output Plength: n by n matrix of pathlengths. Element in 9 | % position (i,j) is pathlength from node i to node j. 10 | % If no path exists, inf is returned. 11 | % 12 | % Description: Powers up the adjacency matrix until either there are 13 | % no elements equal to zero or the (n-1)st power has been 14 | % reached. Records the first power at which (i,j) element 15 | % became nonzero. 16 | % 17 | % Example: Plength = pathlength(A); 18 | % 19 | 20 | % This function was downloaded from the following reference: 21 | % Taylor, A., and D.J. Higham. "Contest: A Controllable Test Matrix Toolbox for % Matlab." ACM Transactions on Mathematical Software (TOMS) 35, no. 4 22 | % (2009): 1-16. 23 | % 24 | 25 | Anew = A; 26 | n = length(A); 27 | power = 1; 28 | Plength = sign(A + eye(n,n)); % record all paths of length one, including diagonal 29 | 30 | while any(any(Anew==0)) && power <= (n-1) 31 | power = power + 1; 32 | Anew = Anew*A; 33 | Plength = Plength + ( (Plength == 0) & (Anew > 0) )*power; 34 | end 35 | 36 | Plength(Plength==0) = inf; % reset zeros to inf 37 | 38 | Plength = Plength - diag(diag(Plength)); % reset diagonal to zero -------------------------------------------------------------------------------- /AnalyzingNeuralTimeSeriesData/code/sampleEEGdata.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vncntprvst/tools/d4c6e382d9de4dfe6e26ba2a34b5f170635f0c7b/AnalyzingNeuralTimeSeriesData/code/sampleEEGdata.mat -------------------------------------------------------------------------------- /AnalyzingNeuralTimeSeriesData/code/solutions2exercises.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vncntprvst/tools/d4c6e382d9de4dfe6e26ba2a34b5f170635f0c7b/AnalyzingNeuralTimeSeriesData/code/solutions2exercises.pdf -------------------------------------------------------------------------------- /AnalyzingNeuralTimeSeriesData/code/tfviewerx.fig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vncntprvst/tools/d4c6e382d9de4dfe6e26ba2a34b5f170635f0c7b/AnalyzingNeuralTimeSeriesData/code/tfviewerx.fig -------------------------------------------------------------------------------- /CellArrayOfStruct2Table.m: -------------------------------------------------------------------------------- 1 | % convert cell array of similar structures to table 2 | 3 | % data=load([dataset '.mat']); %cDn_cmdata.mat top_cortex_cmdata.mat 4 | data.cmdata.alldb=cellfun(@(x) struct2table(x), data.cmdata.alldb,'UniformOutput',false); 5 | data.cmdata.alldb=vertcat(data.cmdata.alldb{:}); 6 | 7 | % save(dataset,'data','-v7.3') -------------------------------------------------------------------------------- /FigViewer/FigViewer.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vncntprvst/tools/d4c6e382d9de4dfe6e26ba2a34b5f170635f0c7b/FigViewer/FigViewer.exe -------------------------------------------------------------------------------- /FigViewer/FigViewer.m: -------------------------------------------------------------------------------- 1 | % to compile into a standalone Figure viewer, run: 2 | % mcc -m -v FigViewer.m 3 | 4 | [fileName,dirPath] = uigetfile('*.fig','Select a figure (.fig) file'); 5 | if any(fileName) 6 | openfig(fullfile(dirPath,fileName)); 7 | end 8 | -------------------------------------------------------------------------------- /FigViewer/FigViewer/PackagingLog.html: -------------------------------------------------------------------------------- 1 |
 2 | mcc -o FigViewer -W WinMain:FigViewer -T link:exe -d V:\Code\Tools\tools\FigViewer\FigViewer\for_testing -v V:\Code\Tools\tools\FigViewer\FigViewer.m -r 'V:\Program Files\MATLAB\R2019a\toolbox\compiler\Resources\default_icon.ico' 
 3 | Compiler version: 7.0.1 (R2019a)
 4 | 
 5 | Dependency analysis by REQUIREMENTS.
 6 | 
 7 | Parsing file "V:\Code\Tools\tools\FigViewer\FigViewer.m"
 8 | 	(referenced from command line).
 9 | Generating file "V:\Code\Tools\tools\FigViewer\FigViewer\for_testing\readme.txt".
10 | Packaging...
11 | Creating the bundle...
12 | Creating the install agent URL file...
13 | Web based installer created at V:\Code\Tools\tools\FigViewer\FigViewer\for_redistribution\MyAppInstaller_web.exe.
14 | Packaging complete.
15 | Elapsed packaging time was: 5 seconds.
16 | 
17 | -------------------------------------------------------------------------------- /FigViewer/FigViewer/for_redistribution/MyAppInstaller_web.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vncntprvst/tools/d4c6e382d9de4dfe6e26ba2a34b5f170635f0c7b/FigViewer/FigViewer/for_redistribution/MyAppInstaller_web.exe -------------------------------------------------------------------------------- /FigViewer/FigViewer/for_redistribution_files_only/FigViewer.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vncntprvst/tools/d4c6e382d9de4dfe6e26ba2a34b5f170635f0c7b/FigViewer/FigViewer/for_redistribution_files_only/FigViewer.exe -------------------------------------------------------------------------------- /FigViewer/FigViewer/for_redistribution_files_only/readme.txt: -------------------------------------------------------------------------------- 1 | FigViewer Executable 2 | 3 | 1. Prerequisites for Deployment 4 | 5 | Verify that version 9.6 (R2019a) of the MATLAB Runtime is installed. 6 | If not, you can run the MATLAB Runtime installer. 7 | To find its location, enter 8 | 9 | >>mcrinstaller 10 | 11 | at the MATLAB prompt. 12 | NOTE: You will need administrator rights to run the MATLAB Runtime installer. 13 | 14 | Alternatively, download and install the Windows version of the MATLAB Runtime for R2019a 15 | from the following link on the MathWorks website: 16 | 17 | http://www.mathworks.com/products/compiler/mcr/index.html 18 | 19 | For more information about the MATLAB Runtime and the MATLAB Runtime installer, see 20 | "Distribute Applications" in the MATLAB Compiler documentation 21 | in the MathWorks Documentation Center. 22 | 23 | 2. Files to Deploy and Package 24 | 25 | Files to Package for Standalone 26 | ================================ 27 | -FigViewer.exe 28 | -MCRInstaller.exe 29 | Note: if end users are unable to download the MATLAB Runtime using the 30 | instructions in the previous section, include it when building your 31 | component by clicking the "Runtime included in package" link in the 32 | Deployment Tool. 33 | -This readme file 34 | 35 | 36 | 37 | 3. Definitions 38 | 39 | For information on deployment terminology, go to 40 | http://www.mathworks.com/help and select MATLAB Compiler > 41 | Getting Started > About Application Deployment > 42 | Deployment Product Terms in the MathWorks Documentation 43 | Center. 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /FigViewer/FigViewer/for_redistribution_files_only/splash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vncntprvst/tools/d4c6e382d9de4dfe6e26ba2a34b5f170635f0c7b/FigViewer/FigViewer/for_redistribution_files_only/splash.png -------------------------------------------------------------------------------- /FigViewer/FigViewer/for_testing/FigViewer.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vncntprvst/tools/d4c6e382d9de4dfe6e26ba2a34b5f170635f0c7b/FigViewer/FigViewer/for_testing/FigViewer.exe -------------------------------------------------------------------------------- /FigViewer/FigViewer/for_testing/mccExcludedFiles.log: -------------------------------------------------------------------------------- 1 | The List of Excluded Files 2 | Excluded files Exclusion Message ID Reason For Exclusion Exclusion Rule 3 | -------------------------------------------------------------------------------- /FigViewer/FigViewer/for_testing/readme.txt: -------------------------------------------------------------------------------- 1 | FigViewer Executable 2 | 3 | 1. Prerequisites for Deployment 4 | 5 | Verify that version 9.6 (R2019a) of the MATLAB Runtime is installed. 6 | If not, you can run the MATLAB Runtime installer. 7 | To find its location, enter 8 | 9 | >>mcrinstaller 10 | 11 | at the MATLAB prompt. 12 | NOTE: You will need administrator rights to run the MATLAB Runtime installer. 13 | 14 | Alternatively, download and install the Windows version of the MATLAB Runtime for R2019a 15 | from the following link on the MathWorks website: 16 | 17 | http://www.mathworks.com/products/compiler/mcr/index.html 18 | 19 | For more information about the MATLAB Runtime and the MATLAB Runtime installer, see 20 | "Distribute Applications" in the MATLAB Compiler documentation 21 | in the MathWorks Documentation Center. 22 | 23 | 2. Files to Deploy and Package 24 | 25 | Files to Package for Standalone 26 | ================================ 27 | -FigViewer.exe 28 | -MCRInstaller.exe 29 | Note: if end users are unable to download the MATLAB Runtime using the 30 | instructions in the previous section, include it when building your 31 | component by clicking the "Runtime included in package" link in the 32 | Deployment Tool. 33 | -This readme file 34 | 35 | 36 | 37 | 3. Definitions 38 | 39 | For information on deployment terminology, go to 40 | http://www.mathworks.com/help and select MATLAB Compiler > 41 | Getting Started > About Application Deployment > 42 | Deployment Product Terms in the MathWorks Documentation 43 | Center. 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /FigViewer/FigViewer/for_testing/requiredMCRProducts.txt: -------------------------------------------------------------------------------- 1 | 35010 35000 -------------------------------------------------------------------------------- /FigViewer/FigViewer/for_testing/splash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vncntprvst/tools/d4c6e382d9de4dfe6e26ba2a34b5f170635f0c7b/FigViewer/FigViewer/for_testing/splash.png -------------------------------------------------------------------------------- /FigViewer/mccExcludedFiles.log: -------------------------------------------------------------------------------- 1 | The List of Excluded Files 2 | Excluded files Exclusion Message ID Reason For Exclusion Exclusion Rule 3 | -------------------------------------------------------------------------------- /FigViewer/readme.txt: -------------------------------------------------------------------------------- 1 | FigViewer Executable 2 | 3 | 1. Prerequisites for Deployment 4 | 5 | Verify that version 9.6 (R2019a) of the MATLAB Runtime is installed. 6 | If not, you can run the MATLAB Runtime installer. 7 | To find its location, enter 8 | 9 | >>mcrinstaller 10 | 11 | at the MATLAB prompt. 12 | NOTE: You will need administrator rights to run the MATLAB Runtime installer. 13 | 14 | Alternatively, download and install the Windows version of the MATLAB Runtime for R2019a 15 | from the following link on the MathWorks website: 16 | 17 | http://www.mathworks.com/products/compiler/mcr/index.html 18 | 19 | For more information about the MATLAB Runtime and the MATLAB Runtime installer, see 20 | "Distribute Applications" in the MATLAB Compiler documentation 21 | in the MathWorks Documentation Center. 22 | 23 | 2. Files to Deploy and Package 24 | 25 | Files to Package for Standalone 26 | ================================ 27 | -FigViewer.exe 28 | -MCRInstaller.exe 29 | Note: if end users are unable to download the MATLAB Runtime using the 30 | instructions in the previous section, include it when building your 31 | component by clicking the "Runtime included in package" link in the 32 | Deployment Tool. 33 | -This readme file 34 | 35 | 36 | 37 | 3. Definitions 38 | 39 | For information on deployment terminology, go to 40 | http://www.mathworks.com/help and select MATLAB Compiler > 41 | Getting Started > About Application Deployment > 42 | Deployment Product Terms in the MathWorks Documentation 43 | Center. 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /FigViewer/requiredMCRProducts.txt: -------------------------------------------------------------------------------- 1 | 35010 35000 -------------------------------------------------------------------------------- /Gdatatheor/README: -------------------------------------------------------------------------------- 1 | These files should be placed in the directory bookchap containing the 2 | basic simulation package. 3 | -------------------------------------------------------------------------------- /GenNoisySig.m: -------------------------------------------------------------------------------- 1 | function noisySig=GenNoisySig(sigDur,sigFreq,sampFreq,phaseShift,numCh) 2 | 3 | % parameters 4 | % sigDur = 3; % Duration (sec) 5 | % sigFreq = 9; % Frequency (Hz) 6 | % sampFreq = 250; % Sampling Frequency (Hz) 7 | % phaseShift = pi/2; 8 | sigAmp = 3; 9 | sigOffset = 0; %1.5; 10 | noiseAmp = 0.5; 11 | 12 | timeVec = linspace(0, sigDur, sampFreq*sigDur); % Time Vector 13 | 14 | % sampInterv = 1/sampFreq; 15 | % timeVec = 0:sampInterv:1-sampInterv; % 1s signal 16 | 17 | %generate signal 18 | for chNum=1:numCh 19 | sig = sigOffset + sigAmp*sin(((2*pi*sigFreq*timeVec))+(phaseShift*chNum)); % % Signal (10 kHz sine) 20 | noisySig(chNum,:) = sig + noiseAmp*(randn(size(sig)));%-0.5 21 | end 22 | 23 | % figure; hold on 24 | % plot(noisySig(1,:)) 25 | % plot(noisySig(end,:)) 26 | 27 | % figure; 28 | % imagesc(noisySig) 29 | 30 | 31 | %% cool effects: 32 | % for chNum=1:64 33 | % sig = sigOffset + sigAmp*sin(2*(pi+0.5*chNum*pi)*sigFreq*timeVec); % Signal (10 kHz sine) 34 | % noisySig(chNum,:) = sig + noiseAmp*(randn(size(sig))-0.5); 35 | % end 36 | % 37 | 38 | % for chNum=1:64 39 | % sig = sigOffset + sigAmp*sin((2*pi+0.5*chNum)*sigFreq*timeVec); % Signal (10 kHz sine) 40 | % noisySig(chNum,:) = sig + noiseAmp*(randn(size(sig))-0.5); 41 | % end 42 | 43 | % for chNum=1:64 44 | % sig = sigOffset + sigAmp*sin(((2*pi*sigFreq)+(pi/2*chNum))*timeVec); % Signal (10 kHz sine) 45 | % noisySig(chNum,:) = sig + noiseAmp*(randn(size(sig))-0.5); 46 | % end 47 | % 48 | % figure; 49 | % imagesc(noisySig) -------------------------------------------------------------------------------- /ImportJRClusSortInfo.m: -------------------------------------------------------------------------------- 1 | function clusterInfo = ImportJRClusSortInfo(filename, startRow, endRow) 2 | % import JRCLus cluster info (spike time, cluster #, max site#) from csv 3 | % file 4 | 5 | %% Initialize variables. 6 | delimiter = ','; 7 | if nargin<=2 8 | startRow = 1; 9 | endRow = inf; 10 | end 11 | 12 | %% Format for each line of text: 13 | formatSpec = '%f%f%f%[^\n\r]'; 14 | 15 | %% Open the text file. 16 | fileID = fopen(filename,'r'); 17 | 18 | %% Read columns of data according to the format. 19 | dataArray = textscan(fileID, formatSpec, endRow(1)-startRow(1)+1, 'Delimiter', delimiter, 'TextType', 'string', 'EmptyValue', NaN, 'HeaderLines', startRow(1)-1, 'ReturnOnError', false, 'EndOfLine', '\r\n'); 20 | for block=2:length(startRow) 21 | frewind(fileID); 22 | dataArrayBlock = textscan(fileID, formatSpec, endRow(block)-startRow(block)+1, 'Delimiter', delimiter, 'TextType', 'string', 'EmptyValue', NaN, 'HeaderLines', startRow(block)-1, 'ReturnOnError', false, 'EndOfLine', '\r\n'); 23 | for col=1:length(dataArray) 24 | dataArray{col} = [dataArray{col};dataArrayBlock{col}]; 25 | end 26 | end 27 | 28 | %% Close the text file. 29 | fclose(fileID); 30 | 31 | %% Create output variable 32 | clusterInfo = table(dataArray{1:end-1}, 'VariableNames', {'timeStamps','clusterNum','bestSite'}); 33 | 34 | -------------------------------------------------------------------------------- /InhCumWeib.m: -------------------------------------------------------------------------------- 1 | function [Inhibition] = InhCumWeib(Params,Data) 2 | %% InhCumWeib 3 | % Fun(gama,XData,alpha,beta,delta) = gama-((exp(-((XData./alpha).^beta))).*(gama-delta)) 4 | % Params: Initial Guess [alpha beta gamma delta]; 5 | 6 | % 1. Get data 7 | if length(Params)<3 8 | Params(3)=1; Params(4)=0; 9 | end 10 | 11 | % 2. Compute Values 12 | % Inhibition = 1 - (Params(3)-((exp(-((Data./Params(1)).^Params(2)))).*(Params(3)-Params(4)))); 13 | 14 | % L Boucher made the following change from the above equation. 15 | Inhibition = (Params(3)-((exp(-((Data./Params(1)).^Params(2)))).*(Params(3)-Params(4)))); -------------------------------------------------------------------------------- /MahalClusDist.m: -------------------------------------------------------------------------------- 1 | 2 | % first tests 3 | load('testexport.mat', 'H66L4A4_22690_stim_Ch2') 4 | waveforms_cls1=H66L4A4_22690_stim_Ch2.values(H66L4A4_22690_stim_Ch2.codes(:,1)==1,:); 5 | waveforms_cls2=H66L4A4_22690_stim_Ch2.values(H66L4A4_22690_stim_Ch2.codes(:,1)==2,:); 6 | PC_cls1=pca(waveforms_cls1); 7 | PC_cls2=pca(waveforms_cls2); 8 | figure 9 | plot(PC_cls1(:,1)) 10 | hold on 11 | plot(PC_cls2(:,1),'r') 12 | figure 13 | plot(waveforms_cls1(1,:)) 14 | hold on 15 | plot(waveforms_cls1(2,:)) 16 | plot(waveforms_cls1(60000,:)) 17 | 18 | % now importing text files saved from Spike2 PCA window (just keep values) 19 | 20 | figure 21 | d = mahal(Clus2,Clus1); 22 | scatter3(Clus1(:,1),Clus1(:,2),Clus1(:,3),10,'o') 23 | hold on 24 | scatter3(Clus2(:,1),Clus2(:,2),Clus2(:,3),10,d,'*','LineWidth',2) 25 | hb = colorbar; 26 | ylabel(hb,'Mahalanobis Distance') 27 | legend('Cluster1','Cluster2','Cluster3','Location','NW') 28 | 29 | 30 | % comparing across epochs 31 | 32 | Clus1=PCAvalues(cluscodes==1,:); 33 | Clus1_s1=Clus1(1:ceil(size(Clus1,1)/3),:); 34 | Clus1_s2=Clus1(ceil(size(Clus1,1)/3)+1:ceil(size(Clus1,1)/3*2),:); 35 | % Clus1_s3=Clus1(ceil(size(Clus1,1)/3*2)+1:end,:); 36 | d1vs1 = mahal(Clus1_s1,Clus1_s1); 37 | d2vs1 = mahal(Clus1_s2,Clus1_s1); 38 | 39 | olvals=d2vs1(d2vs1>(mean(d1vs1)+2.5*std(d1vs1))); -------------------------------------------------------------------------------- /MakeASCII4.m: -------------------------------------------------------------------------------- 1 | function MakeASCII4(whichfile, whatch) 2 | load([whichfile '.mat']); 3 | eval(['data = ' whichfile '_Ch' num2str(whatch,'%d')]); 4 | 5 | FID = fopen([whichfile '.txt'], 'w'); 6 | eno = 0; 7 | fprintf(FID, '%d\t%d\tet\n',25,data.items); 8 | data.times = round(data.times.*50000); 9 | data.values = abs(data.values); 10 | for a = 1:25 11 | newrow = []; 12 | for b = 1:data.items 13 | if (b == data.items) 14 | newrow = [newrow sprintf('%7.7f',data.values(a,b))]; 15 | else 16 | newrow = [newrow sprintf('%7.7f\t',data.values(a,b))]; 17 | end 18 | end 19 | if a == 25 20 | fprintf(FID, ['%d\t%d\t' newrow],eno,data.times(a)); 21 | else 22 | fprintf(FID, ['%d\t%d\t' newrow '\n'],eno,data.times(a)); 23 | %keyboard; 24 | end 25 | end 26 | fclose(FID); 27 | %keyboard; 28 | end -------------------------------------------------------------------------------- /Matlab2Goog/README.txt: -------------------------------------------------------------------------------- 1 | 2011/04/27 2 | This set of matlab functions will allow creating 3 | Google spreadsheets, adding worksheets to them, modifying the 4 | worksheets, and placing data in them. The delete worksheet 5 | function works intermittently so far (the DELETE request throws 6 | 400/Bad request sometimes). 7 | 8 | Please see Matlab2GoogTest.m for sample usage (you'll need to 9 | enter your gmail username/password). 10 | 11 | Please note that you need to have urlreadwrite.m (unmodified as 12 | available in the Matlab distribution in 13 | MATLABROOT/toolbox/matlab/iofun/private/urlreadwrite.m) on your 14 | path. 15 | 16 | This was very much inspired by submission of Ofir Bibi (Create 17 | Google Calendar event with SMS and Email notification, File ID: 18 | #25698). 19 | 20 | 2011/6/20 21 | The Google login box was inspired by submission of Matt Fig (41 22 | Complete GUI Examples, File ID: #24861). Some of the code was 23 | somewhat simplified, there is a new function, getWorksheetCell, 24 | that reads both the cell value and the forumula. editWorksheetCell 25 | supports entering formulas as string (see Google Spreadsheet 26 | API for examples). 27 | -------------------------------------------------------------------------------- /Matlab2Goog/deleteSpreadsheet.m: -------------------------------------------------------------------------------- 1 | function deleteSpreadsheet(spreadsheetKey,aToken) 2 | import java.io.*; 3 | import java.net.*; 4 | import java.lang.*; 5 | com.mathworks.mlwidgets.html.HTMLPrefs.setProxySettings; 6 | 7 | MAXITER=10; 8 | success=false; 9 | 10 | getURLStringList=['https://docs.google.com/feeds/default/private/full/' spreadsheetKey '?delete=true']; 11 | safeguard=0; 12 | while (~success && safeguard 0) 15 | %randomly select a pair of rows 16 | %fix() rounds-down to the nearest integer 17 | pos1 = 1+fix(nrows * rand); 18 | pos2 = 1+fix(nrows * rand); 19 | %swap the randomly selected rows 20 | temp = table(pos1); 21 | table(pos1) = table(pos2); 22 | table(pos2) = temp; 23 | %decrement swap counter 24 | count = count - 1; 25 | end 26 | 27 | %another approach to creating a randomized list is to use randperm() 28 | %as follows. However, experimentation with this approach suggests 29 | %that the randomization algorithm appears to "neglect" the early 30 | %items in the list...Anyway, that's my opinion and I'm sticking with it. 31 | % 32 | %rand('state',sum(100 * clock)); %seed random number generator 33 | %order=randperm(10); %create randomized list for numbers 1 thru 10 -------------------------------------------------------------------------------- /ResamplingStats/SchieberLabResamplingStats/randperm2.m: -------------------------------------------------------------------------------- 1 | function [s1,s2]=randperm2(universe,n1) 2 | % 3 | % [s1,s2] = randperm2(universe,n1) 4 | % Generates two permutation samples taken from 'universe'. 5 | % Sample 's1' has a size equal to 'n1'. 6 | % The size of 's2' = length(universe)-n1. 7 | 8 | %make sure to previously seed the random number generator as per: 9 | %rand('state',sum(100*clock)); 10 | 11 | n=numel(universe); 12 | n2=n-n1; 13 | rp=randperm(n); 14 | y=rp(1:n1); 15 | s1=universe(y); 16 | y2=rp(n1+1:n); 17 | s2=universe(y2); 18 | -------------------------------------------------------------------------------- /ResamplingStats/correlation.m: -------------------------------------------------------------------------------- 1 | function c = correlation(mat) 2 | tmp = corrcoef(mat(:,1),mat(:,2)); 3 | c = tmp(1,2); -------------------------------------------------------------------------------- /ResamplingStats/nonansem.m: -------------------------------------------------------------------------------- 1 | function m=nonansem(y) 2 | %m=nonansem(y) 3 | %Calculates sem of matrix m, ignoring nans. 4 | 5 | for i=1:size(y,2) 6 | m(i)=std(y(~isnan(y(:,i)),i)); 7 | numreals = length(y(:,i))-sum(isnan(y(:,i))); 8 | m(i)=m(i)/sqrt(numreals); 9 | end -------------------------------------------------------------------------------- /ResamplingStats/nonanstd.m: -------------------------------------------------------------------------------- 1 | function m=nonanstd(y) 2 | %m=nonanstd(y) 3 | %Calculates std of matrix m, ignoring nans. 4 | 5 | for i=1:size(y,2) 6 | m(i)=std(y(~isnan(y(:,i)),i)); 7 | end -------------------------------------------------------------------------------- /ResamplingStats/resampling_statistical_toolkit/__MACOSX/statistics/._README.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vncntprvst/tools/d4c6e382d9de4dfe6e26ba2a34b5f170635f0c7b/ResamplingStats/resampling_statistical_toolkit/__MACOSX/statistics/._README.txt -------------------------------------------------------------------------------- /ResamplingStats/resampling_statistical_toolkit/__MACOSX/statistics/._statcond.m: -------------------------------------------------------------------------------- 1 | Mac OS X  2 RMATFMATL -------------------------------------------------------------------------------- /ResamplingStats/resampling_statistical_toolkit/license.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2010, Arnaud Delorme 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in 12 | the documentation and/or other materials provided with the distribution 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 18 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /ResamplingStats/shuffle.m: -------------------------------------------------------------------------------- 1 | function [Y,index] = shuffle(X) 2 | % [Y,index] = shuffle(X) 3 | % 4 | % Randomly sorts X. 5 | % If X is a vector, sorts all of X, so Y = X(index). 6 | % If X is an m-by-n matrix, sorts each column of X, so 7 | % for j=1:n, Y(:,j)=X(index(:,j),j). 8 | % 9 | % Also see SORT, Sample, and Randi. 10 | % 11 | % xx/xx/92 dh Brainard Wrote it. 12 | % 10/25/93 dhb Return index. 13 | % 5/25/96 dgp Made consistent with sort and "for i=Shuffle(1:10)" 14 | % 6/29/96 dgp Edited comments above. 15 | [~,index] = sort(rand(size(X))); 16 | Y = X(index); -------------------------------------------------------------------------------- /SEM_calc.m: -------------------------------------------------------------------------------- 1 | function sem=SEM_calc(vect, CI) 2 | % SEM_calc - standard error of the mean, confidence interval 3 | % 4 | % function sem=SEM_calc(vect, CI) 5 | % 6 | % Purpose 7 | % Calculate the standard error the mean to a given confidence 8 | % interval (CI). Note that nans do not contribute to the 9 | % calculation of the sample size and are ignored for the SD 10 | % calculation. Output of this function has been checked against 11 | % known working code written in R. 12 | % 13 | % Inputs 14 | % - vect: A vector upon which the SEM will be calculated. Note that 15 | % if vect is a matrix then we calculate one SEM for each 16 | % column. 17 | % 18 | % - CI [optional]: a p value for a different 2-tailed interval. e.g. 0.01 19 | % This is a 2-tailed interval. 20 | % 21 | % Outputs 22 | % sem - the standard error of the mean. So to plot the interval it's mu-sem 23 | % to mu+sem. 24 | % 25 | % Example - plot a 1% interval [rather than the default %5] 26 | % r=randn(1,30); 27 | % S=SEM_calc(r,0.01); 28 | % hist(r) 29 | % hold on 30 | % plot(mean(r), mean(ylim),'r*') 31 | % plot([mean(r)-S,mean(r)+S], [mean(ylim),mean(ylim)],'r-') 32 | % hold off 33 | % 34 | % Rob Campbell 35 | % 36 | % Also see - tInterval_Calc, norminv 37 | 38 | error(nargchk(1,2,nargin)) 39 | 40 | if isvector(vect) 41 | vect=vect(:); 42 | end 43 | 44 | 45 | if nargin==1 46 | stdCI = 1.96 ; 47 | elseif nargin==2 48 | CI = CI/2 ; %Convert to 2-tail 49 | stdCI = abs(norminv(CI,0,1)) ; 50 | end 51 | 52 | sem = ( (nanstd(vect)) ./ sqrt(sum(~isnan(vect))) ) * stdCI ; -------------------------------------------------------------------------------- /SHdaq2csv.m: -------------------------------------------------------------------------------- 1 | % export SpikeHound (.daq) files to text file, for import to Spike2 2 | 3 | dir='E:\Data\Recordings\Sixx\SHrec\'; 4 | file='S115L4A6_12871'; 5 | 6 | datainfo=daqread([dir file],'info'); 7 | data=daqread([dir file]); 8 | % export trigger channel into _t file as a structure with title 'trigger', 9 | % then remove channel 10 | 11 | % write only data channel for export to spike2 12 | csvwrite('S115L4A6_12871.csv',data); 13 | 14 | % can one call the spike2 import script? 15 | % C:\Spike7\scripts\IMPTEXT.S2S 16 | -------------------------------------------------------------------------------- /SelectElipse.m: -------------------------------------------------------------------------------- 1 | rng default; 2 | 3 | % 3d plot 4 | % rndData = [randn(100,3)*0.75+ones(100,3); 5 | % randn(100,3)*0.5-ones(100,3)]; 6 | % 7 | % figure; 8 | % plotH=scatter3(rndData(:,1),rndData(:,2),rndData(:,3),'.'); hold on 9 | % title 'Random Data'; 10 | 11 | rndData = [randn(100,2)*0.75+ones(100,2); 12 | randn(100,2)*0.5-ones(100,2)]; 13 | 14 | figure; 15 | plotH=scatter(rndData(:,1),rndData(:,2),'.'); hold on 16 | title 'Random Data'; 17 | 18 | ellipseSelectionH = imellipse; 19 | 20 | selectPos=ellipseSelectionH.getPosition; 21 | 22 | selectIdx=rndData(:,1)>=selectPos(1) & rndData(:,1)<=(selectPos(1)+selectPos(3)) &... 23 | rndData(:,2)>=selectPos(2) & rndData(:,2)<=(selectPos(2)+selectPos(4)); 24 | 25 | scatter(rndData(selectIdx,1),rndData(selectIdx,2),'r.'); 26 | 27 | % better indexing with meshgrid (but circular selection) 28 | [rr, cc] = meshgrid(min(rndData(:,1)):max(rndData(:,1)),... 29 | min(rndData(:,2)):max(rndData(:,2))); 30 | selectionIdx = sqrt((rr-selectPos(1)+selectPos(3)/2).^2+(cc-selectPos(2)+selectPos(4)/2).^2)<=... 31 | min([selectPos(3) selectPos(4)]); 32 | -------------------------------------------------------------------------------- /ShuffledClassification.m: -------------------------------------------------------------------------------- 1 | function [classification, timing]=ShuffledClassification(trialsData,numShuffles) 2 | if nargin<2 3 | numShuffles=10000; 4 | end 5 | 6 | %% count the fraction of trials during which a particular time bin had calcium events 7 | numTrials=size(trialsData,1); 8 | caEventFraction=sum(logical(trialsData))/numTrials; 9 | % figure; plot(caEventFraction); 10 | 11 | %% shuffle calcium events in time to build null distribution. 12 | trialsData=num2cell(trialsData',1); 13 | nullDdistrib=nan(numShuffles,1); 14 | % shuffle numShuffles times, find max value 15 | for shuffleNum=1:numShuffles 16 | nullDdistrib(shuffleNum)=max(sum(logical(cell2mat(cellfun(@(x) x(randperm(10)),... 17 | trialsData,'UniformOutput', false))'))/numTrials); 18 | end 19 | 20 | %much faster shuffle: http://www.mathworks.com/matlabcentral/fileexchange/27076-shuffle 21 | 22 | %% Find 95th percentile 23 | sem = std(nullDdistrib)/sqrt(numShuffles); 24 | confidenceInterval = mean(nullDdistrib) + sem*1.96; 25 | 26 | %% compare actual peak to 95th percentile of the shuffled peaks 27 | if max(caEventFraction(16:end))>confidenceInterval %restricted to pre-post movement 28 | classification=1; 29 | timing=[find(caEventFraction>confidenceInterval,1);... % (16:end) 30 | find(caEventFraction>=max(caEventFraction(16:end)),1)]; % (16:end) 31 | else 32 | classification=0; 33 | timing=[NaN;NaN]; 34 | end 35 | 36 | -------------------------------------------------------------------------------- /adinstruments_sdk_matlab/+adi/+examples/conversion_speed_testing.m: -------------------------------------------------------------------------------- 1 | function conversion_speed_testing 2 | % 3 | % 4 | % conversion_speed_testing 5 | % 6 | % 7 | % TODO: This should be moved to the testing package. 8 | 9 | root_path = 'C:\Data\GSK\ChrisRaw'; 10 | root_path = 'C:\D\GSK_Data'; 11 | 12 | base_file = '140207 control cmg.'; 13 | file_path = fullfile(root_path,[base_file 'adicht']); 14 | mat_fpath = fullfile(root_path,[base_file 'mat']); 15 | h5_fpath = fullfile(root_path,[base_file 'h5']); 16 | 17 | %Converting the file to mat format 18 | %--------------------------------- 19 | if false 20 | tic; 21 | adinstruments.convert(file_path,'format','mat'); 22 | toc; 23 | end 24 | 25 | %Summary: 26 | %File Size : 105 MB 27 | %Total Time: 28 seconds 28 | %163 reads of 21 channels (105 MB total) - 7.4 s 29 | %Remaining time is mostly writing 30 | 31 | %Converting the file to h5 format 32 | %-------------------------------- 33 | if false 34 | tic; 35 | adinstruments.convert(file_path,'format','h5'); 36 | toc; 37 | end 38 | 39 | if false 40 | tic; 41 | h = load(mat_fpath,'data__chan_3_rec_4'); 42 | toc; 43 | end 44 | %# Values: 91,434,500 - 730 MB in memory - on disk maybe 50 MB 45 | %Channel read time: 2.637 seconds 46 | 47 | 48 | 49 | if false 50 | tic 51 | wtf = adinstruments.readFile(h5_fpath); 52 | toc 53 | 54 | c = wtf.channel_specs(3); 55 | 56 | tic 57 | data = c.getAllData(2); 58 | toc 59 | 60 | tic 61 | h = load(mat_fpath,'data__chan_3_rec_2'); 62 | toc 63 | end 64 | 65 | file_obj = h5m.file.open(h5_fpath); 66 | 67 | keyboard 68 | 69 | group_obj = h5m.group.open(file_obj,'/data__chan_3_rec_2'); 70 | 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /adinstruments_sdk_matlab/+adi/+examples/e001_writeFileFromScratch.m: -------------------------------------------------------------------------------- 1 | function e001_writeFileFromScratch 2 | % 3 | % adi.examples.e001_writeFileFromScratch 4 | % 5 | % In this file I wrote many more eus samples than presssure but the 6 | % Labchart loader didn't show all of the eus data 7 | % 8 | % I'm not sure why this is occuring but the big lesson seems to be that 9 | % the program doesn't completely freak out if this happens 10 | % 11 | % TODO: See if we can do this from a template file 12 | 13 | N_RECORDS = 4; 14 | 15 | file_path = 'C:\Users\RNEL\Desktop\merge_adi_test\wtf.adicht'; 16 | 17 | if exist(file_path,'file') 18 | delete(file_path) 19 | end 20 | 21 | fw = adi.createFile(file_path); 22 | %fw : adi.file_writer 23 | 24 | %fw.addComment(1,300,'Does this actually work?') 25 | %fw.addComment(7,300,'Does this actually work?') 26 | 27 | pres_w = fw.addChannel(1,'Pressure',1000,'cmH2O'); 28 | eus_w = fw.addChannel(2,'eus',200,'uV'); 29 | 30 | for iRecord = 1:2 %N_RECORDS 31 | fw.startRecord; 32 | 33 | %fprintf(2,'Pressure \n'); 34 | pres_w.addSamples((1:1000)/1000) 35 | pres_w.addSamples((1:1000)/1000) 36 | pres_w.addSamples((1:1000)/1000) 37 | pres_w.addSamples((1:1000)/1000) 38 | pres_w.addSamples((1:1000)/1000) 39 | %t=0:0.001:2; 40 | 41 | %fprintf(2,'Onto EUS \n'); 42 | t = 0.001:0.001:1; 43 | 44 | y=chirp(t,0,1,150); 45 | eus_w.addSamples(y); 46 | 47 | %fw.addComment(1,2,'Cheeseburgers are great'); 48 | 49 | c_number = fw.addComment(iRecord,3,'Testing3','channel',1); 50 | fw.addComment(iRecord,4,'Testing4'); 51 | fw.addComment(iRecord,5,'Testing5'); 52 | 53 | fw.stopRecord; 54 | end 55 | 56 | 57 | 58 | fw.save; 59 | fw.close; 60 | clear fw 61 | clear all -------------------------------------------------------------------------------- /adinstruments_sdk_matlab/+adi/+examples/e002_addCommentsToAnExistingFile.m: -------------------------------------------------------------------------------- 1 | function e002_addCommentsToAnExistingFile() 2 | % 3 | % Why doesn't this work??? 4 | % 5 | % Is there some problem with modifying old adicht files that 6 | % weren't created with the sdk? 7 | 8 | file_path = 'C:\temp\example_labchart_file.adicht'; 9 | 10 | fw = adi.editFile(file_path); 11 | 12 | %fw.addComment(1,300,'Does this actually work?') 13 | fw.addComment(7,300,'Does this actually work?') 14 | 15 | 16 | %Fails on this line 17 | fw.save -------------------------------------------------------------------------------- /adinstruments_sdk_matlab/+adi/+sdk/ReadMe.md: -------------------------------------------------------------------------------- 1 | I'd eventually like to move all the SDKs into this folder. 2 | 3 | The main sdk would be the LabChart SDK -------------------------------------------------------------------------------- /adinstruments_sdk_matlab/+adi/+sl/+cellstr/join.m: -------------------------------------------------------------------------------- 1 | function str = join(cellstr_input,varargin) 2 | %toString 3 | % 4 | % str = sl.cellstr.join(cellstr_input,varargin) 5 | % 6 | % INPUTS 7 | % ======================================================================= 8 | % cellstr : A cell array of strings to combine. 9 | % 10 | % OPTIONAL INPUTS 11 | % ======================================================================= 12 | % d : (default ','), delimiter string to use in combining strings 13 | % 14 | % To treat a delimiter as a literal escape the backlash with a 15 | % backlash. For example, this '\\t' will join strings with '\t' 16 | % instead of a tab. Percents should be escaped with a percent. 17 | % 18 | % The final delimiter => sprintf(delim) 19 | % 20 | % remove_empty : (default false), if true empty values are removed 21 | % 22 | % EXAMPLES 23 | % ======================================================================= 24 | % 25 | % TODO: Finish Documentation 26 | 27 | in.d = ','; 28 | in.remove_empty = false; 29 | in = adi.sl.in.processVarargin(in,varargin); 30 | 31 | if isempty(cellstr_input) 32 | str = ''; 33 | elseif ~iscell(cellstr_input) 34 | error('Input to %s must be a cell array',mfilename) 35 | else 36 | P = cellstr_input(:)'; 37 | if in.remove_empty 38 | P(cellfun('isempty',P)) = []; 39 | if isempty(P) 40 | str = ''; 41 | return 42 | end 43 | end 44 | P(2,:) = {sprintf(in.d)} ; %Added on printing to handle things like \t and \n 45 | 46 | P{2,end} = [] ; 47 | str = sprintf('%s',P{:}); 48 | end -------------------------------------------------------------------------------- /adinstruments_sdk_matlab/+adi/+sl/+datetime/getTimeZone.m: -------------------------------------------------------------------------------- 1 | function utc_offset = getTimeZone 2 | %getTimeZone Returns the time zone of the operating system. 3 | % 4 | % utc_offset = sl.datetime.getTimeZone 5 | % 6 | % Uses a Java call. This function is necessary for converting between 7 | % Matlab time which is local based, and many other time codes which are 8 | % all UTC based. 9 | % 10 | % OUTPUTS 11 | % ======================================================================= 12 | % utc_offset : # of hours different from UTC the computer is. For 13 | % example, a computer using Eastern Standard Time will return -5 14 | 15 | 16 | %Java call 17 | tz = java.util.TimeZone.getDefault; %in ms 18 | 19 | %convert to hours 20 | %1000 ms/s * 60 s/min * 60 min/hour 21 | utc_offset = tz.getRawOffset/3600000; -------------------------------------------------------------------------------- /adinstruments_sdk_matlab/+adi/+sl/+datetime/unixToMatlab.m: -------------------------------------------------------------------------------- 1 | function matlab_time = unixToMatlab(unix_time,utc_offset) 2 | %unixTimeToMatlabTime Converts unix time to Matlab time 3 | % 4 | % matlab_time = sl.datetime.unixToMatlab(unix_time,*utc_offset) 5 | % 6 | % INPUTS 7 | % ======================================================================= 8 | % unixTime - (element or vector), unix time, # of non-leap seconds since 9 | % January 1, 1970 10 | % 11 | % OPTIONAL INPUTS 12 | % ======================================================================= 13 | % utc_offset - (default, use local), -5 corresponds to EST 14 | % 15 | % OUTPUTS 16 | % ======================================================================= 17 | % matlab_time - double, fraction represents seconds, the integer part of 18 | % the #, floor(matlabTime) represents the # of days since A.D. 19 | % 20 | % See Also: 21 | % sl.datetime.getTimeZone 22 | 23 | 24 | if ~exist('utc_offset','var') || isempty(utc_offset) 25 | utc_offset = adi.sl.datetime.getTimeZone; 26 | end 27 | 28 | SECONDS_IN_DAY = 86400; 29 | UNIX_EPOCH = 719529; 30 | matlab_time = unix_time./SECONDS_IN_DAY + UNIX_EPOCH + utc_offset/24; -------------------------------------------------------------------------------- /adinstruments_sdk_matlab/+adi/+sl/+dir/changeFileExtension.m: -------------------------------------------------------------------------------- 1 | function new_file_path = changeFileExtension(file_path,new_extension) 2 | % 3 | % new_file_path = sl.dir.changeFileExtension(file_path,new_extension) 4 | % 5 | % This is a simple helper function that makes it obvious what is being 6 | % done (i.e. changing the file extension). 7 | % 8 | % Inputs: 9 | % ------- 10 | % file_path: str 11 | % Path to the file. It may be absolute or relative. 12 | % new_extension: str 13 | % The extension that the file_path should have when returned from 14 | % this function. This may or may not contain a leading period. 15 | % 16 | % Example: 17 | % -------- 18 | % file_path = 'C:\a\b.mat' 19 | % new_file_path = sl.dir.changeFileExtension(file_path,'txt') 20 | % new_file_path => 'C:\a\b.txt' 21 | 22 | 23 | %Ensure dot is present as first character 24 | if new_extension(1) ~= '.' 25 | new_extension = ['.' new_extension]; 26 | end 27 | 28 | [a,b] = fileparts(file_path); 29 | 30 | new_file_path = fullfile(a,[b new_extension]); 31 | 32 | 33 | end -------------------------------------------------------------------------------- /adinstruments_sdk_matlab/+adi/+sl/+dir/filepartsx.m: -------------------------------------------------------------------------------- 1 | function path_out = filepartsx(file_or_folder_path,N) 2 | %filepartsx Applies fileparts() function numerous times 3 | % 4 | % path_out = sl.dir.filepartsx(file_or_folder_path,N) 5 | % 6 | % Small function to help clean up stripping of the path. 7 | % 8 | % INPUTS: 9 | % ------- 10 | % file_or_folder_path : path to file or folder 11 | % N : # of times to apply fileparts() function 12 | % 13 | % Example: 14 | % -------- 15 | % file_path = 'C:\my_dir1\my_dir2\my_file.txt'; 16 | % path_out = sl.dir.filepartsx(file_path,2); 17 | % 18 | % path_out => 'C:\my_dir1' 19 | 20 | path_out = file_or_folder_path; 21 | for iN = 1:N 22 | path_out = fileparts(path_out); 23 | end 24 | 25 | end -------------------------------------------------------------------------------- /adinstruments_sdk_matlab/+adi/+sl/+stack/getPackageRoot.m: -------------------------------------------------------------------------------- 1 | function package_root = getPackageRoot() 2 | % 3 | % package_root = sl.stack.getPackageRoot() 4 | % 5 | % Returns the path of the folder that contains the base package. 6 | % 7 | % Examples: 8 | % Called from: 'C:\repos\matlab_git\my_repo\+package\my_function.m 9 | % Returns: 'C:\repos\matlab_git\my_repo\' 10 | % 11 | 12 | temp_path = adi.sl.stack.getMyBasePath('','n_callers_up',1); 13 | 14 | I = strfind(temp_path,'+'); 15 | if isempty(I) 16 | package_root = temp_path; 17 | else 18 | last_char_I = I(1)-2; 19 | package_root = temp_path(1:last_char_I); 20 | end 21 | 22 | end 23 | -------------------------------------------------------------------------------- /adinstruments_sdk_matlab/+adi/@file_viewer/private/main.fig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vncntprvst/tools/d4c6e382d9de4dfe6e26ba2a34b5f170635f0c7b/adinstruments_sdk_matlab/+adi/@file_viewer/private/main.fig -------------------------------------------------------------------------------- /adinstruments_sdk_matlab/+adi/binary_file_writer.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vncntprvst/tools/d4c6e382d9de4dfe6e26ba2a34b5f170635f0c7b/adinstruments_sdk_matlab/+adi/binary_file_writer.m -------------------------------------------------------------------------------- /adinstruments_sdk_matlab/+adi/createFile.m: -------------------------------------------------------------------------------- 1 | function file_writer = createFile(file_path,varargin) 2 | % 3 | % file_writer = adi.createFile(file_path) 4 | % 5 | % This is a work in progress 6 | % 7 | 8 | in.copy_blank_when_new = false; 9 | in = adi.sl.in.processVarargin(in,varargin); 10 | 11 | is_new = ~exist(file_path,'file'); 12 | 13 | %Possibilities 14 | %1) create new file de novo 15 | %2) create new file using a copy of a blank file as a starting point 16 | %3) edit a file that already exists 17 | 18 | if is_new 19 | if in.copy_blank_when_new 20 | adi.createBlankFileAtPath(file_path) 21 | file_h = adi.sdk.openFile(file_path,'read_and_write',true); 22 | else 23 | file_h = adi.sdk.createFile(file_path); 24 | end 25 | else 26 | file_h = adi.sdk.openFile(file_path,'read_and_write',true); 27 | end 28 | %file_h : adi.file_handle 29 | 30 | data_writer_h = adi.sdk.createDataWriter(file_h); 31 | %data_writer_h : adi.data_writer_handle 32 | 33 | file_writer = adi.file_writer(file_path, file_h, data_writer_h, is_new); 34 | 35 | end -------------------------------------------------------------------------------- /adinstruments_sdk_matlab/+adi/data_writer_handle.m: -------------------------------------------------------------------------------- 1 | classdef (Hidden) data_writer_handle < handle 2 | % 3 | % Class: 4 | % adi.data_writer_handle 5 | % 6 | % See Also: 7 | % --------- 8 | % adi.createFile 9 | % adi.file_handle 10 | 11 | properties 12 | pointer_value 13 | end 14 | 15 | methods 16 | function obj = data_writer_handle(pointer_value) 17 | obj.pointer_value = pointer_value; 18 | end 19 | function delete(obj) 20 | adi.sdk.closeWriter(obj.pointer_value) 21 | end 22 | end 23 | 24 | end 25 | 26 | -------------------------------------------------------------------------------- /adinstruments_sdk_matlab/+adi/documentation/FunctionMapping.csv: -------------------------------------------------------------------------------- 1 | Header_Order,DLL Function Name,mex option,Matlab Name,Notes 2 | 1,ADI_OpenFile,0,openFile, 3 | 2,ADI_CreateFile,NYI,, 4 | 3,ADI_GetErrorMessage,14,, 5 | 4,ADI_TickToSamplePos,NYI,, 6 | 5,ADI_SamplePosToTick,NYI,, 7 | 6,ADI_GetNumberOfRecords,1,, 8 | 7,ADI_GetNumberOfChannels,2,, 9 | 8,ADI_GetNumTicksInRecord,3,, 10 | 9,ADI_GetRecordTickPeriod,4,, 11 | 10,ADI_GetNumSamplesInRecord,5,, 12 | 11,ADI_GetRecordSamplePeriod,15,getSamplePeriod, 13 | 12,ADI_GetRecordTime,16,, 14 | 13,ADI_CreateCommentsAccessor,6,, 15 | 14,ADI_CloseCommentsAccessor,7,, 16 | 15,ADI_GetCommentInfo,8,, 17 | 16,ADI_NextComment,9,, 18 | 17,ADI_GetSamples,10,, 19 | 18,ADI_GetUnitsName,11,, 20 | 19,ADI_GetChannelName,12,, 21 | 20,ADI_SetChannelName,NYI,, 22 | 21,ADI_CreateWriter,NYI,, 23 | 22,ADI_SetChannelInfo,NYI,, 24 | 23,ADI_StartRecord,NYI,, 25 | 24,ADI_AddChannelSamples,NYI,, 26 | 25,ADI_FinishRecord,NYI,, 27 | 26,ADI_CommitFile,NYI,, 28 | 27,ADI_CloseWriter,NYI,, 29 | 28,ADI_AddComment,NYI,, 30 | 29,ADI_DeleteComment,NYI,, 31 | 30,ADI_CloseFile,13,closeFile, 32 | -------------------------------------------------------------------------------- /adinstruments_sdk_matlab/+adi/editFile.m: -------------------------------------------------------------------------------- 1 | function file_writer = editFile(file_path,varargin) 2 | %x Open a file for editing 3 | % 4 | % file_writer = adi.editFile(file_path) 5 | % 6 | % 7 | 8 | if ~exist(file_path,'file') 9 | error('File to edit doesn''t exist:\n%s',file_path) 10 | end 11 | 12 | file_h = adi.sdk.openFile(file_path,'read_and_write',true); 13 | 14 | data_writer_h = adi.sdk.createDataWriter(file_h); 15 | 16 | file_writer = adi.file_writer(file_path, file_h, data_writer_h, false); 17 | 18 | end -------------------------------------------------------------------------------- /adinstruments_sdk_matlab/+adi/file_handle.m: -------------------------------------------------------------------------------- 1 | classdef (Hidden) file_handle < handle 2 | % 3 | % Class: 4 | % adi.file_handle 5 | % 6 | % This class is simply meant to hold the reference to an open file. 7 | % When no one holds it the file will be closed. 8 | 9 | properties 10 | pointer_value %Pointer to the file object in the mex code. This gets 11 | %cast to ADI_FileHandle in the mex code. 12 | file_path 13 | end 14 | 15 | methods 16 | function obj = file_handle(pointer_value,file_path) 17 | % 18 | % Inputs: 19 | % ------- 20 | % pointer_value: 21 | % file_path: 22 | 23 | obj.pointer_value = pointer_value; 24 | obj.file_path = file_path; 25 | end 26 | function delete(obj) 27 | % 28 | % 29 | % fprintf(2,'ADI SDK - Deleting file ref: %s\n',obj.file_name); 30 | 31 | adi.handle_logger.logOperation(obj.file_path,'closeFile',obj.pointer_value) 32 | adi.sdk.closeFile(obj.pointer_value); 33 | end 34 | end 35 | 36 | end 37 | 38 | -------------------------------------------------------------------------------- /adinstruments_sdk_matlab/+adi/file_read_options.m: -------------------------------------------------------------------------------- 1 | classdef file_read_options < handle 2 | % 3 | % Class: 4 | % adi.file_read_options 5 | % 6 | % Contains reading options. Currently this is for all file formats. 7 | 8 | properties %All file formats: 9 | %adi.file 10 | remove_empty_channels = true; %If true, channels without data for 11 | %all records are removed. 12 | channels_remove = {} %TODO: On setting ensure it is a cell array 13 | % 14 | % This should be a cell array of channels which you wish to not 15 | % include when reading the file. 16 | 17 | %conversion_max_ 18 | end 19 | 20 | properties %Mat file format only 21 | load_all_mat_on_start = true; %Not yet linked to the method 22 | %See: adi.mat_file_h 23 | end 24 | 25 | methods 26 | end 27 | 28 | end 29 | 30 | -------------------------------------------------------------------------------- /adinstruments_sdk_matlab/+adi/h5_conversion_options.m: -------------------------------------------------------------------------------- 1 | classdef h5_conversion_options < handle 2 | % 3 | % Class: 4 | % adi.h5_conversion_options 5 | % 6 | % See Also: 7 | % adi.channel.exportToHDF5File 8 | 9 | properties 10 | max_samples_per_read = 1e8 11 | deflate_value = 3 %(0 - 9 for gzip 12 | %0 - no compression 13 | %9 - most compression 14 | % 15 | % NOTE: At some point with gzip the data fail to compress any 16 | % more. 17 | use_shuffle = false 18 | chunk_length = 1e8 %Ideally this would be linked to 19 | %'max_samples_per_read' but for now this is ok 20 | end 21 | 22 | properties (Dependent) 23 | chunk_length_pct 24 | end 25 | 26 | methods 27 | function set.chunk_length_pct(obj,value) 28 | obj.chunk_length = round(obj.max_samples_per_read*value); 29 | end 30 | end 31 | 32 | end 33 | 34 | -------------------------------------------------------------------------------- /adinstruments_sdk_matlab/+adi/handle_logger.m: -------------------------------------------------------------------------------- 1 | classdef (Hidden) handle_logger < handle 2 | % 3 | % Class: 4 | % adi.handle_logger 5 | % 6 | % This is hopefully a temporary class that logs open and close 7 | % operations. 8 | 9 | properties 10 | fid 11 | end 12 | 13 | methods 14 | %TODO: Make private 15 | function obj = handle_logger() 16 | %Call this via: 17 | % 18 | % % % % % repo_root = adi.sl.stack.getPackageRoot; 19 | % % % % % file_path = fullfile(repo_root,'temp_logger.txt'); 20 | % % % % % obj.fid = fopen(file_path,'a'); 21 | end 22 | function delete(obj) 23 | % % % % fclose(obj.fid); 24 | end 25 | end 26 | 27 | methods (Static) 28 | function logOperation(file_path,handle_type,handle_value) 29 | % 30 | % adi.handle_logger.logOperation(file_path,handle_type,handle_value) 31 | % 32 | % Inputs: 33 | % ------- 34 | % file_path : 35 | % Labchart file that is being referenced (not the save 36 | % path) 37 | % handle_type : string 38 | % Who is calling the logger? 39 | % handle_value : integer 40 | 41 | % % % % persistent obj 42 | % % % % 43 | % % % % if isempty(obj) 44 | % % % % obj = adi.handle_logger; 45 | % % % % end 46 | % % % % 47 | % % % % %write_str = sprintf('%s %s:\t%s:%ld\n',datestr(now),file_path,handle_type,handle_value); 48 | % % % % fwrite(obj.fid,write_str); 49 | end 50 | end 51 | 52 | end 53 | 54 | -------------------------------------------------------------------------------- /adinstruments_sdk_matlab/+adi/mat_conversion_options.m: -------------------------------------------------------------------------------- 1 | classdef mat_conversion_options 2 | % 3 | % Class: 4 | % adi.mat_conversion_options 5 | % 6 | % Nothing needed yet! 7 | 8 | properties 9 | end 10 | 11 | methods 12 | end 13 | 14 | end 15 | 16 | -------------------------------------------------------------------------------- /adinstruments_sdk_matlab/+adi/mat_file_h.m: -------------------------------------------------------------------------------- 1 | classdef (Hidden) mat_file_h < handle 2 | % 3 | % Class: 4 | % adi.mat_file_h 5 | 6 | properties 7 | m %Handle to the file. 8 | end 9 | 10 | methods 11 | function obj = mat_file_h(file_path,varargin) 12 | % 13 | % obj = adi.mat_file_h(file_path,varargin) 14 | % 15 | % Optional Inputs: 16 | % ---------------- 17 | % load_all : logical (default false) 18 | % If true the entire file is loaded into memory at once, 19 | % otherwise the 'matfile' commend and the subsequent 20 | % 'matlab.io.MatFile' class are used. Loading everything 21 | % might makes things slightly faster but it also might be 22 | % a lot slower if only analyzing a portion of the file. 23 | % It might also cause an "out of memory" error. 24 | % 25 | % See Also: 26 | % adi.readFile 27 | 28 | %TODO: Link this to input options in read file 29 | 30 | in.load_all = false; 31 | in = adi.sl.in.processVarargin(in,varargin); 32 | if in.load_all 33 | obj.m = load(file_path); 34 | else 35 | obj.m = matfile(file_path,'Writable',false); 36 | end 37 | end 38 | function delete(obj) 39 | %TODO: Delete 40 | end 41 | end 42 | 43 | end 44 | 45 | -------------------------------------------------------------------------------- /adinstruments_sdk_matlab/+adi/private/c.m: -------------------------------------------------------------------------------- 1 | function output = c(input) 2 | 3 | output = int32(input); 4 | end -------------------------------------------------------------------------------- /adinstruments_sdk_matlab/+adi/private/c0.m: -------------------------------------------------------------------------------- 1 | function output = c0(input) 2 | % 3 | % Helper function for correcting inputs to the mex function 4 | 5 | output = int32(input-1); -------------------------------------------------------------------------------- /adinstruments_sdk_matlab/+adi/private/clong.m: -------------------------------------------------------------------------------- 1 | function num_out = clong(num_in) 2 | % 3 | % Convert to long type 4 | % 5 | % For right now I'm using int32, might need an 'if' statement at some 6 | % point 7 | num_out = int32(num_in); 8 | end -------------------------------------------------------------------------------- /adinstruments_sdk_matlab/+adi/private/sdk_mex.mexw32: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vncntprvst/tools/d4c6e382d9de4dfe6e26ba2a34b5f170635f0c7b/adinstruments_sdk_matlab/+adi/private/sdk_mex.mexw32 -------------------------------------------------------------------------------- /adinstruments_sdk_matlab/+adi/private/sdk_mex.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vncntprvst/tools/d4c6e382d9de4dfe6e26ba2a34b5f170635f0c7b/adinstruments_sdk_matlab/+adi/private/sdk_mex.mexw64 -------------------------------------------------------------------------------- /adinstruments_sdk_matlab/.gitignore: -------------------------------------------------------------------------------- 1 | /temp_logger.txt 2 | *.asv 3 | *.bin 4 | *.m~ 5 | interfaceConverterCode 6 | 7 | #Copied from: 8 | #https://help.github.com/articles/ignoring-files 9 | 10 | # Compiled source # 11 | ################### 12 | *.com 13 | *.class 14 | *.exe 15 | *.o 16 | *.so 17 | 18 | # Packages # 19 | ############ 20 | # it's better to unpack these files and commit the raw source 21 | # git has its own built in compression methods 22 | *.7z 23 | *.dmg 24 | *.gz 25 | *.iso 26 | *.jar 27 | *.rar 28 | *.tar 29 | *.zip 30 | 31 | # Logs and databases # 32 | ###################### 33 | *.log 34 | *.sql 35 | *.sqlite 36 | 37 | # OS generated files # 38 | ###################### 39 | .DS_Store 40 | .DS_Store? 41 | ._* 42 | .Spotlight-V100 43 | .Trashes 44 | Icon? 45 | ehthumbs.db 46 | Thumbs.db 47 | 48 | -------------------------------------------------------------------------------- /adinstruments_sdk_matlab/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Jim Hokanson 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /adinstruments_sdk_matlab/documentation/ReadMe.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vncntprvst/tools/d4c6e382d9de4dfe6e26ba2a34b5f170635f0c7b/adinstruments_sdk_matlab/documentation/ReadMe.md -------------------------------------------------------------------------------- /adinstruments_sdk_matlab/documentation/organization.md: -------------------------------------------------------------------------------- 1 | ---------------- 2 | The Labchart SDK 3 | ---------------- 4 | This file is meant to briefly discuss how this repo came about and how the code is organized. 5 | 6 | This code is based on the Labchart SDK provided by ADInstruments. An installer for 7 | the SDK can be found in the Labchart folder following installation of Labchart. 8 | The SDK provides a Windows dll and information on what functions are available 9 | in the dll. 10 | 11 | A mex file has been written that calls these dll functions from Matlab. 12 | A separate set of Matlab functions exist that expose this mex file to Matlab. 13 | These functions are currently located in adi.sdk (although I plan on moving this). 14 | 15 | On top of these functions I've written classes that make it slightly easier 16 | to work with the SDK. 17 | 18 | ------------------- 19 | Code in the Library 20 | ------------------- 21 | 22 | The adi package contains all relevant code. 23 | 24 | Within the adi package are meant to be relevant entry points. 25 | Ideally I want to move most of the non-entry functions outside of the base package but this is a very low priority 26 | 27 | Entry functions include: (may be outdated) 28 | - adi.readFile 29 | - adi.createFile 30 | - adi.editFile 31 | - adi.convert -------------------------------------------------------------------------------- /adinstruments_sdk_matlab/files/LabChartBinaryFormat.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vncntprvst/tools/d4c6e382d9de4dfe6e26ba2a34b5f170635f0c7b/adinstruments_sdk_matlab/files/LabChartBinaryFormat.pdf -------------------------------------------------------------------------------- /adinstruments_sdk_matlab/files/blank_labchart_8_file.adicht: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vncntprvst/tools/d4c6e382d9de4dfe6e26ba2a34b5f170635f0c7b/adinstruments_sdk_matlab/files/blank_labchart_8_file.adicht -------------------------------------------------------------------------------- /adinstruments_sdk_matlab/files/crash_testing.m: -------------------------------------------------------------------------------- 1 | %Running this code enough will cause the program to crash 2 | % 3 | % I think this suggests that if the file is somehow open in on place that 4 | % it shouldn't be opened again in another. 5 | % 6 | % Suggested fix: When trying to open a file, see if it is in memory. 7 | % Problem: I'm not sure how to hold onto the file and yet not allow the 8 | % object to be destroyed. 9 | 10 | %EXPT_ID = '141010_J'; %crashes on Palidin 11 | %EXPT_ID = '140414_C'; %might crash, needs more testing 12 | %EXPT_ID = ''140724_C'; %can crash, takes some work 13 | 14 | for i = 1:100 15 | EXPT_ID = '141010_J'; 16 | c = dba.GSK.cmg_expt(EXPT_ID); 17 | pres_data = c.getData('pres'); 18 | c2 = dba.GSK.cmg_expt(EXPT_ID); 19 | pres_data2 = c2.getData('pres'); 20 | 21 | clear c 22 | clear c2 23 | clear pres_data 24 | clear pres_data2 25 | 26 | c = dba.GSK.cmg_expt(EXPT_ID); 27 | pres_data = c.getData('pres'); 28 | end -------------------------------------------------------------------------------- /aes/AES_GET_COUNTER.m: -------------------------------------------------------------------------------- 1 | function [out] = AES_GET_COUNTER(i) 2 | % AES_GET_COUNTER Generates counter for aes.m - an example. 3 | % Example function implemented to simulate counter for aestest. 4 | % Change this function to correspond to your requirements. 5 | % i: counter call number; 1, 2, 3,... 6 | % out: counter value for given counter call 7 | 8 | % Stepan Matejka, 2011, matejka[at]feld.cvut.cz 9 | % $Revision: 1.1.0 $ $Date: 2011/10/12 $ 10 | 11 | counterh = {'f0' 'f1' 'f2' 'f3' 'f4' 'f5' 'f6' 'f7'... 12 | 'f8' 'f9' 'fa' 'fb' 'fc' 'fd' 'fe' 'ff'}; 13 | counter = hex2dec(counterh); 14 | 15 | switch (i) 16 | case 1 17 | out = counter; 18 | case 2 19 | counter(15:16) = [255 0]; 20 | out = counter; 21 | case 3 22 | counter(15:16) = [255 1]; 23 | out = counter; 24 | case 4 25 | counter(15:16) = [255 2]; 26 | out = counter; 27 | otherwise 28 | error('Index out of bounds.'); 29 | end 30 | 31 | % ------------------------------------------------------------------------ 32 | % end of file 33 | -------------------------------------------------------------------------------- /aes/Contents.m: -------------------------------------------------------------------------------- 1 | % AES 2 | % 3 | % Files 4 | % aes - Encrypt/decrypt array of bytes by AES. 5 | % AES_GET_COUNTER - Generates counter for aes.m - an example. 6 | % aesdecrypt - Decrypt 16-bytes vector. 7 | % aesencrypt - Encrypt 16-bytes vector. 8 | % aesinfo - Display info about AES setting in AES structure. 9 | % aesinit - Generate structure with s-boxes, expanded key, etc. 10 | % aestest - AES test script. 11 | -------------------------------------------------------------------------------- /aes/Readme.m: -------------------------------------------------------------------------------- 1 | % AES-128, AES-192, and AES-256 encryption/decription functions. 2 | % Download up-to-date version from 3 | % http://radio.feld.cvut.cz/personal/matejka/wiki/doku.php?id=root:en:projects 4 | % Stepan Matejka, 2011, matejka[at]feld.cvut.cz 5 | % $Revision: 1.1.0 $ $Date: 2011/11/20 $ 6 | % 7 | % Files: 8 | % High level functions: 9 | % aesinit - Generate structure with s-boxes, expanded key, etc. 10 | % aes - Encrypt/decrypt array of bytes by AES. 11 | % aesinfo - Display info about AES setting in AES structure. 12 | % Low level 4x4 block functions: 13 | % aesdecrypt - Decrypt 16-bytes vector. 14 | % aesencrypt - Encrypt 16-bytes vector. 15 | % Test functions: 16 | % aestest - AES test script. 17 | % AES_GET_COUNTER - Generates counter for aes.m - an example. 18 | -------------------------------------------------------------------------------- /alpha_filtconv.m: -------------------------------------------------------------------------------- 1 | function filtvals = alpha_filtconv(vector,sigma) 2 | % 8/2013 - VP. Based on formula from Abbott and Dayan 3 | % Neural Encoding I: Firing Rates and Spike Statistics 4 | % Using alpha function to create causal kernel: 5 | % firing rate at time t only depends on spikes fired before t 6 | 7 | if nargin < 2 || isempty(sigma) 8 | sigma = 5; 9 | end 10 | 11 | size = 6*sigma; 12 | x = linspace(-size / 2, size / 2, size); 13 | alpha = 1/sigma; 14 | alphaFilter = ((alpha^2)*x) .* exp(-alpha*x); 15 | alphaFilter(alphaFilter<0)=0; 16 | alphaFilter = alphaFilter / sum (alphaFilter); % normalize 17 | % rectify shift 18 | 19 | filtvals = conv (vector, alphaFilter, 'same'); -------------------------------------------------------------------------------- /batch/readme.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /catamaran_spike_sorting/catamaran_doc.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vncntprvst/tools/d4c6e382d9de4dfe6e26ba2a34b5f170635f0c7b/catamaran_spike_sorting/catamaran_doc.pdf -------------------------------------------------------------------------------- /catamaran_spike_sorting/readme.txt: -------------------------------------------------------------------------------- 1 | README for Catamaran Spike Sorting Software. 2 | 3 | catamaran.m, version 1.3, 27 February 2012 4 | nttfile.m, version 2.0, 15 February 2012 5 | 6 | Catamaran is a program to facilitate the sorting of action potentials (spikes) 7 | recorded by tetrodes and stored in Neuralynx NTT files. 8 | 9 | System Requirements: 10 | Platform independent (tested on WIndows XP, Windows 7, Macintosh OS X, and Ubuntu GNU/Linux). 11 | Requires MATLAB 7.6 (R2008a) or newer. 12 | Requires Statistics and Signal Processing Toolboxes. 13 | 14 | Installation: 15 | Put catamaran.m and nttfile.m in any folder on your MATLAB path. 16 | 17 | Operation: 18 | Type "catamaran" at the MATLAB prompt. 19 | 20 | Read the accompanying documentation in catamaran_doc.pdf. 21 | 22 | 23 | 24 | No warranties are expressed or implied. 25 | 26 | 27 | Douglas M. Schwarz 28 | Dept. of Neurobiology & Anatomy 29 | University of Rochester 30 | Rochester, NY USA 31 | -------------------------------------------------------------------------------- /clustering/calcAUROC.m: -------------------------------------------------------------------------------- 1 | %function to calculate area under ROC curve. 2 | 3 | %inputs as follows: 4 | %data: spike density functions in the form of an m x n matrix, m = trials, 5 | %n = time, for ONE neuron. PLEASE make window range a number divisible by 100 6 | %baselinewindow: vector in the form [o p] showing which columns of data matrix are defined as baseline period 7 | %please make baseline window a number divisible by 100. (ie. if first 200 8 | %ms of sdf are your baseline period, baselinewindow = [1 200]; 9 | 10 | 11 | function [AUC] = calcAUROC(data,baselinewindow) 12 | n = size(data,2); 13 | 14 | if rem(n,100) > 0 15 | error('Please make the columns of your data matrix a number divisible by 100') 16 | end 17 | 18 | if rem(baselinewindow(2),100)>0 19 | error('Please make size of baseline window a number divisible by 100') 20 | end 21 | 22 | iteraterange = reshape(1:n,[],n/100); 23 | colval = baselinewindow(2)/100; 24 | base = data(:,reshape(iteraterange(:,1:colval),1,[])); 25 | base = reshape(base,1,[]); 26 | 27 | % compute AUC over 100ms epochs 28 | AUC = zeros(1,size(iteraterange,2)-colval); 29 | for j = colval+1:size(iteraterange,2) 30 | fr = reshape(data(:,iteraterange(:,j)),1,[]); 31 | if max(fr)==0 & max(base)==0 32 | AUC(j-(colval))=0; 33 | else 34 | [~,~,AUC(j-(colval))] = simpleROC(base,fr); 35 | end 36 | end 37 | end -------------------------------------------------------------------------------- /clustering/clusterROC.m: -------------------------------------------------------------------------------- 1 | %function which clustered data 2 | %input: 3 | %ROCarray: ROC data formatted in an mxn matrix, where m equals number of 4 | %neurons, n = rows of ROC data calculated by running calcAUROC on data 5 | % clusternumber: intended number of clustered to be created 6 | 7 | %output: clusterind (indices assigning each row to a cluster) 8 | %output plot: silhouette analysis on clustered data 9 | 10 | function [clusterind] = clusterROC(ROCarray,clusternumber) 11 | clustind = kmeans(1-corr(ROCarray'),5,'dist','cityblock'); 12 | silhouette(1-corr(cell2mat(temp')'),clust) 13 | end -------------------------------------------------------------------------------- /clustering/simpleROC.m: -------------------------------------------------------------------------------- 1 | function [FPR,TPR,AUC] = simpleROC(baseline,fr) 2 | a = max(baseline); 3 | b = max(fr); 4 | maxcrit = max([a b]); 5 | FPR = zeros(1,length(0:ceil(maxcrit))); 6 | TPR = FPR; 7 | range = fliplr(0:ceil(maxcrit)); 8 | 9 | for i = 1:length(range) 10 | crit = range(i); 11 | temp1 = length(find(baseline>crit))/length(baseline); 12 | temp2 = length(find(fr>crit))/length(fr); 13 | FPR(i) = temp1; 14 | TPR(i) = temp2; 15 | end 16 | 17 | if isscalar(FPR) || isscalar(TPR) 18 | AUC=0; 19 | else 20 | AUC = trapz(FPR,TPR); 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /density_estimation-master/.gitignore: -------------------------------------------------------------------------------- 1 | dev/ 2 | tmp/ 3 | track/ 4 | *~ 5 | _* 6 | *.mat 7 | *.log 8 | *.asv 9 | *.eps 10 | *.DS_Store 11 | -------------------------------------------------------------------------------- /density_estimation-master/ref/shimazaki_jcns10.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vncntprvst/tools/d4c6e382d9de4dfe6e26ba2a34b5f170635f0c7b/density_estimation-master/ref/shimazaki_jcns10.pdf -------------------------------------------------------------------------------- /density_estimation-master/ref/shimazaki_neco07.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vncntprvst/tools/d4c6e382d9de4dfe6e26ba2a34b5f170635f0c7b/density_estimation-master/ref/shimazaki_neco07.pdf -------------------------------------------------------------------------------- /fconvert.m: -------------------------------------------------------------------------------- 1 | %%File converter: Converts the daq file to a bin file 2 | function[]=fconvert(filename) 3 | %filename=input('Which file do you want to convert? \n','s'); 4 | 5 | %Load DAQ file and information 6 | info=daqread([filename '.daq'],'info'); 7 | [data time]=daqread([filename '.daq']); 8 | 9 | %Create the file 10 | binfile=[filename '.bin']; 11 | fid=fopen(binfile,'a'); 12 | 13 | fwrite(fid,data','float'); %writes data to the file 14 | fclose(fid); 15 | 16 | end -------------------------------------------------------------------------------- /findauc.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vncntprvst/tools/d4c6e382d9de4dfe6e26ba2a34b5f170635f0c7b/findauc.m -------------------------------------------------------------------------------- /fread_workingresize.m: -------------------------------------------------------------------------------- 1 | function mnWav1 = fread_workingresize(fid_bin, dimm, vcDataType) 2 | % obsolete for Matlab 2017+, if not earlier 3 | % Get around fread bug (matlab) where built-in fread resize doesn't work 4 | % From JRCLUST v3 5 | % James Jun 6 | try 7 | if isempty(dimm) 8 | mnWav1 = fread(fid_bin, inf, ['*', vcDataType]); 9 | else 10 | mnWav1 = fread(fid_bin, prod(dimm), ['*', vcDataType]); 11 | if numel(mnWav1) == prod(dimm) 12 | mnWav1 = reshape(mnWav1, dimm); 13 | else 14 | dimm2 = floor(numel(mnWav1) / dimm(1)); 15 | if dimm2 >= 1 16 | mnWav1 = reshape(mnWav1, dimm(1), dimm2); 17 | else 18 | mnWav1 = []; 19 | end 20 | end 21 | end 22 | catch 23 | disperr_(); 24 | end 25 | end %func -------------------------------------------------------------------------------- /gauss_filtconv.m: -------------------------------------------------------------------------------- 1 | function filtvals = gauss_filtconv(vector,sigma) 2 | % Smoothing with simple gaussian filtering, using limited kernel that lacks 3 | % denominator (such as 1/(sqrt(2*pi)*fixedsigma) in front of the exponential) 4 | % -> simply have kernel with much wider area under curve. 5 | % Results after filtering are typically similar, though. 6 | % For conversion to spike rate, see spike_density 7 | 8 | if nargin < 2 || isempty(sigma) 9 | sigma = 5; 10 | end 11 | 12 | size = 6*sigma; 13 | x = linspace(-size / 2, size / 2, size); 14 | gaussFilter = exp(-x .^ 2 / (2 * sigma ^ 2)); 15 | gaussFilter = gaussFilter / sum (gaussFilter); % normalize 16 | 17 | filtvals = conv (vector, gaussFilter, 'same'); -------------------------------------------------------------------------------- /gaussfilt.m: -------------------------------------------------------------------------------- 1 | % GAUSSFILT - Small wrapper function for convenient Gaussian filtering 2 | % 3 | % Usage: smim = gaussfilt(im, sigma) 4 | % 5 | % Arguments: im - Image to be smoothed. 6 | % sigma - Standard deviation of Gaussian filter. 7 | % 8 | % Returns: smim - Smoothed image. 9 | % 10 | % If called with sigma = 0 the function immediately returns with im assigned 11 | % to smim 12 | % 13 | % See also: INTEGGAUSSFILT 14 | 15 | % Peter Kovesi 16 | % Centre for Explortion Targeting 17 | % The University of Western Australia 18 | % http://www.csse.uwa.edu.au/~pk/research/matlabfns/ 19 | 20 | % March 2010 21 | % June 2013 - Provision for multi-channel images 22 | 23 | function smim = gaussfilt(im, sigma) 24 | 25 | if sigma < eps 26 | smim = im; 27 | return; 28 | end 29 | 30 | % If needed convert im to double 31 | if ~strcmp(class(im),'double') 32 | im = double(im); 33 | end 34 | 35 | sze = max(ceil(6*sigma), 1); 36 | if ~mod(sze,2) % Ensure filter size is odd 37 | sze = sze+1; 38 | end 39 | 40 | h = fspecial('gaussian', [sze sze], sigma); 41 | 42 | % Apply filter to all image channels 43 | smim = zeros(size(im)); 44 | for n = 1:size(im,3) 45 | smim(:,:,n) = filter2(h, im(:,:,n)); 46 | end 47 | -------------------------------------------------------------------------------- /gen_nonhomoPoissonProc.m: -------------------------------------------------------------------------------- 1 | function gen_nonhomoPoissonProc 2 | 3 | % % homogeneous poisson coeff 4 | % y=poissrnd(0.5,1,100); 5 | % y(y>0)=1; 6 | % X=1:100; 7 | % coeff = glmfit(X, y,'poisson') 8 | 9 | %************************************************************************** 10 | %This is the matlab program of non homogeneous Poisson Process. 11 | %Using the Algorithm:- 12 | %(1)Set T(0)=0 and i=1. 13 | %(2)Gnerate an independent random variable U(i)~U(0,1). 14 | %(3)Set T(i+1)=T(i)-(1/lambda)ln(U(i)). 15 | %(4)if T(i)>Tmax, Stop. 16 | %(5)set lambdat =a*(T(i+1))^(-b); a>0, b<1. 17 | %(6)Gnerate an independent random variable u(i)~U(0,1). 18 | %(7)If u(i)<=lambdat/lambda, set i=i+1 and S(i)=T(i)and go to Step (2). 19 | % i: number of event at time T and S(1),...,S(i): the event times. 20 | % Program is written by Mr. Jitendra Singh (M.Tech student). 21 | %************************************************************************** 22 | 23 | lambda=input('Enter The arrival Rate:'); % arrival rate 24 | Tmax=input('Enter maximum time:'); % maximum time 25 | clear T; 26 | T(1)= 0; 27 | a=input('Enter constant a>0:'); 28 | b=input('Enter constant b<1:'); 29 | S(1)=0; 30 | i=1; 31 | 32 | while T(i) < Tmax, 33 | U(i)=rand(1,1); 34 | T(i+1)=T(i)-(1/lambda)*(log(U(i))); 35 | lambdat=a*(T(i+1))^(-b); 36 | u(i)=rand(1,1); 37 | if u(i)<=lambdat/lambda 38 | i=i+1; 39 | S(i)=T(i); 40 | end 41 | end 42 | plot(S(1:(i)), 0:(i-1)); 43 | title(['A Sample path of the non homogeneous Poisson process']); 44 | xlabel(['Time interval']); 45 | ylabel([' Number of event ']); 46 | 47 | %************************************************************************** -------------------------------------------------------------------------------- /graphic_interface_toolkit/__MACOSX/guifunc/._README.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vncntprvst/tools/d4c6e382d9de4dfe6e26ba2a34b5f170635f0c7b/graphic_interface_toolkit/__MACOSX/guifunc/._README.txt -------------------------------------------------------------------------------- /graphic_interface_toolkit/__MACOSX/guifunc/._inputgui.m: -------------------------------------------------------------------------------- 1 | Mac OS X  2 RMATFMATL -------------------------------------------------------------------------------- /graphic_interface_toolkit/guifunc/.svn/all-wcprops: -------------------------------------------------------------------------------- 1 | K 25 2 | svn:wc:ra_dav:version-url 3 | V 54 4 | /repos/software/!svn/ver/8882/eeglab/functions/guifunc 5 | END 6 | inputgui.m 7 | K 25 8 | svn:wc:ra_dav:version-url 9 | V 65 10 | /repos/software/!svn/ver/8880/eeglab/functions/guifunc/inputgui.m 11 | END 12 | listdlg2.m 13 | K 25 14 | svn:wc:ra_dav:version-url 15 | V 65 16 | /repos/software/!svn/ver/8880/eeglab/functions/guifunc/listdlg2.m 17 | END 18 | pophelp.m 19 | K 25 20 | svn:wc:ra_dav:version-url 21 | V 64 22 | /repos/software/!svn/ver/8880/eeglab/functions/guifunc/pophelp.m 23 | END 24 | inputdlg2.m 25 | K 25 26 | svn:wc:ra_dav:version-url 27 | V 66 28 | /repos/software/!svn/ver/8880/eeglab/functions/guifunc/inputdlg2.m 29 | END 30 | questdlg2.m 31 | K 25 32 | svn:wc:ra_dav:version-url 33 | V 66 34 | /repos/software/!svn/ver/8882/eeglab/functions/guifunc/questdlg2.m 35 | END 36 | warndlg2.m 37 | K 25 38 | svn:wc:ra_dav:version-url 39 | V 65 40 | /repos/software/!svn/ver/8880/eeglab/functions/guifunc/warndlg2.m 41 | END 42 | errordlg2.m 43 | K 25 44 | svn:wc:ra_dav:version-url 45 | V 66 46 | /repos/software/!svn/ver/8880/eeglab/functions/guifunc/errordlg2.m 47 | END 48 | finputcheck.m 49 | K 25 50 | svn:wc:ra_dav:version-url 51 | V 68 52 | /repos/software/!svn/ver/8880/eeglab/functions/guifunc/finputcheck.m 53 | END 54 | supergui.m 55 | K 25 56 | svn:wc:ra_dav:version-url 57 | V 65 58 | /repos/software/!svn/ver/8880/eeglab/functions/guifunc/supergui.m 59 | END 60 | -------------------------------------------------------------------------------- /graphic_interface_toolkit/guifunc/.svn/text-base/errordlg2.m.svn-base: -------------------------------------------------------------------------------- 1 | % errordlg2() - Makes a popup dialog box with the specified message and (optional) 2 | % title. 3 | % 4 | % Usage: 5 | % errordlg2(Prompt, Title); 6 | % 7 | % Example: 8 | % errordlg2('Explanation of error','title of error'); 9 | % 10 | % Input: 11 | % Prompt - A text string explaning why the user is seeing this error message. 12 | % Title _ A text string that appears in the title bar of the error message. 13 | % 14 | % Author: Arnaud Delorme, CNL / Salk Institute, 12 August 2002 15 | % 16 | % See also: inputdlg2(), questdlg2() 17 | 18 | % Copyright (C) Arnaud Delorme, CNL / Salk Institute, arno@salk.edu 19 | % 20 | % This program is free software; you can redistribute it and/or modify 21 | % it under the terms of the GNU General Public License as published by 22 | % the Free Software Foundation; either version 2 of the License, or 23 | % (at your option) any later version. 24 | % 25 | % This program is distributed in the hope that it will be useful, 26 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 27 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 28 | % GNU General Public License for more details. 29 | % 30 | % You should have received a copy of the GNU General Public License 31 | % along with this program; if not, write to the Free Software 32 | % Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 33 | 34 | function errordlg2(Prompt, Title); 35 | 36 | if exist('beep') == 5 37 | beep; 38 | else 39 | disp(char(7)); 40 | end; 41 | if nargin <2 42 | Title = 'Error'; 43 | end; 44 | questdlg2(Prompt, Title, 'OK', 'OK'); 45 | -------------------------------------------------------------------------------- /graphic_interface_toolkit/guifunc/.svn/text-base/warndlg2.m.svn-base: -------------------------------------------------------------------------------- 1 | % warndlg2() - same as warndlg for eeglab() 2 | % 3 | % Author: Arnaud Delorme, CNL / Salk Institute, 12 August 2002 4 | % 5 | % See also: inputdlg2(), questdlg2() 6 | 7 | % Copyright (C) Arnaud Delorme, CNL / Salk Institute, arno@salk.edu 8 | % 9 | % This program is free software; you can redistribute it and/or modify 10 | % it under the terms of the GNU General Public License as published by 11 | % the Free Software Foundation; either version 2 of the License, or 12 | % (at your option) any later version. 13 | % 14 | % This program is distributed in the hope that it will be useful, 15 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | % GNU General Public License for more details. 18 | % 19 | % You should have received a copy of the GNU General Public License 20 | % along with this program; if not, write to the Free Software 21 | % Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | 23 | function warndlg2(Prompt, Title); 24 | 25 | if nargin <2 26 | Title = 'Warning'; 27 | end; 28 | questdlg2(Prompt, Title, 'OK', 'OK'); 29 | -------------------------------------------------------------------------------- /graphic_interface_toolkit/guifunc/errordlg2.m: -------------------------------------------------------------------------------- 1 | % errordlg2() - Makes a popup dialog box with the specified message and (optional) 2 | % title. 3 | % 4 | % Usage: 5 | % errordlg2(Prompt, Title); 6 | % 7 | % Example: 8 | % errordlg2('Explanation of error','title of error'); 9 | % 10 | % Input: 11 | % Prompt - A text string explaning why the user is seeing this error message. 12 | % Title _ A text string that appears in the title bar of the error message. 13 | % 14 | % Author: Arnaud Delorme, CNL / Salk Institute, 12 August 2002 15 | % 16 | % See also: inputdlg2(), questdlg2() 17 | 18 | % Copyright (C) Arnaud Delorme, CNL / Salk Institute, arno@salk.edu 19 | % 20 | % This program is free software; you can redistribute it and/or modify 21 | % it under the terms of the GNU General Public License as published by 22 | % the Free Software Foundation; either version 2 of the License, or 23 | % (at your option) any later version. 24 | % 25 | % This program is distributed in the hope that it will be useful, 26 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 27 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 28 | % GNU General Public License for more details. 29 | % 30 | % You should have received a copy of the GNU General Public License 31 | % along with this program; if not, write to the Free Software 32 | % Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 33 | 34 | function errordlg2(Prompt, Title); 35 | 36 | if exist('beep') == 5 37 | beep; 38 | else 39 | disp(char(7)); 40 | end; 41 | if nargin <2 42 | Title = 'Error'; 43 | end; 44 | questdlg2(Prompt, Title, 'OK', 'OK'); 45 | -------------------------------------------------------------------------------- /graphic_interface_toolkit/guifunc/warndlg2.m: -------------------------------------------------------------------------------- 1 | % warndlg2() - same as warndlg for eeglab() 2 | % 3 | % Author: Arnaud Delorme, CNL / Salk Institute, 12 August 2002 4 | % 5 | % See also: inputdlg2(), questdlg2() 6 | 7 | % Copyright (C) Arnaud Delorme, CNL / Salk Institute, arno@salk.edu 8 | % 9 | % This program is free software; you can redistribute it and/or modify 10 | % it under the terms of the GNU General Public License as published by 11 | % the Free Software Foundation; either version 2 of the License, or 12 | % (at your option) any later version. 13 | % 14 | % This program is distributed in the hope that it will be useful, 15 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | % GNU General Public License for more details. 18 | % 19 | % You should have received a copy of the GNU General Public License 20 | % along with this program; if not, write to the Free Software 21 | % Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | 23 | function warndlg2(Prompt, Title); 24 | 25 | if nargin <2 26 | Title = 'Warning'; 27 | end; 28 | questdlg2(Prompt, Title, 'OK', 'OK'); 29 | -------------------------------------------------------------------------------- /graphic_interface_toolkit/license.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2010, Arnaud Delorme 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in 12 | the documentation and/or other materials provided with the distribution 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 18 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /instantfr.m: -------------------------------------------------------------------------------- 1 | function [ifr,tt] = instantfr(t_spk,tt) 2 | % INSTANTFR - Instantaneous firing rate of a spike train 3 | % ifr = INSTANTFR(t_spk, tt) calculates the instantaneous firing rate 4 | % at times TT of a spike train with spikes at times T_SPK. 5 | % In the interval between two spikes I and I+1, the instanteous firing 6 | % rate IFR is defined as: 7 | % 8 | % IFR = 1 / (T_SPK(I+1) - T_SPK(I). 9 | % 10 | % Even though there is no natural definition for the IFR before the first 11 | % spike or after the last spike in a train, this function sets IFR to zero 12 | % in those intervals. 13 | % 14 | % [ifr,tt] = INSTANTFR(t_spk) automatically picks suitable time points, 15 | % in practice, just before and just after each spike. 16 | 17 | epsi = 1e-6; 18 | 19 | tt0 = [t_spk(:)' - epsi; t_spk(:)' + epsi]; 20 | idt = [diff([0 t_spk(:)']); diff([t_spk(:)' inf])]; 21 | tt0 = tt0(:)'; 22 | idt = idt(:)'; 23 | if nargin<2 24 | ifr = 1./idt(2:end-1); 25 | tt = tt0(2:end-1); 26 | if size(t_spk,1)~=1 27 | ifr=ifr'; 28 | tt=tt'; 29 | end 30 | else 31 | if isempty(t_spk) 32 | ifr=0*tt; 33 | return; 34 | end 35 | idt1 = inf;%tt0(1)-tt(1); 36 | idtn = inf;%tt(end)-tt0(end); 37 | ifr0 = 1./[idt1 idt1 idt(2:end-1) idtn idtn]; 38 | tt0 = [tt(1) tt0 tt(end)]; 39 | ifr = interp1(tt0,ifr0,tt,'linear'); 40 | if size(tt,1)~=1 41 | ifr=ifr'; 42 | end 43 | end 44 | if nargout<2 45 | clear tt 46 | end 47 | -------------------------------------------------------------------------------- /latency_analysis.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vncntprvst/tools/d4c6e382d9de4dfe6e26ba2a34b5f170635f0c7b/latency_analysis.m -------------------------------------------------------------------------------- /linspecer/license.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015, Jonathan C. Lansey 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in 12 | the documentation and/or other materials provided with the distribution 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 18 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /linspecer/linspecer.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vncntprvst/tools/d4c6e382d9de4dfe6e26ba2a34b5f170635f0c7b/linspecer/linspecer.m -------------------------------------------------------------------------------- /m2vbColor.m: -------------------------------------------------------------------------------- 1 | %% Convert Matlab color to a VBA color (Microsoft decimal RGB format: 0xRRGGBB) 2 | function color = m2vbColor(color) 3 | try 4 | % Convert color names to RBG triple (0-1) if not already in that format 5 | if ischar(color) 6 | switch lower(color) 7 | case {'y','yellow'}, color = [1,1,0]; 8 | case {'m','magenta'}, color = [1,0,1]; 9 | case {'c','cyan'}, color = [0,1,1]; 10 | case {'r','red'}, color = [1,0,0]; 11 | case {'g','green'}, color = [0,1,0]; 12 | case {'b','blue'}, color = [0,0,1]; 13 | case {'w','white',''}, color = [1,1,1]; % empty '' also sets white color 14 | case {'k','black'}, color = [0,0,0]; 15 | otherwise, error(['Invalid color specified: ' color]); 16 | end 17 | elseif ~isnumeric(color) | length(color)~=3 %#ok ML6 18 | error(['Invalid color specified: ' color]); 19 | end 20 | 21 | % Convert to Microsoft decimal RGB format 22 | color = sum(floor(color*255) .* (256.^[0,1,2])); %or sum(floor(color*255) .* (256.^[2,1,0])); ?? 23 | catch 24 | error(['Invalid color specified: ' lasterr]); 25 | end 26 | 27 | -------------------------------------------------------------------------------- /make_movie_from_signal.m: -------------------------------------------------------------------------------- 1 | %% get data 2 | fileName='example'; 3 | 4 | % reading actual video: 5 | % vidObj = VideoReader([fileName '.avi']); 6 | 7 | % reading from file 8 | % load([fileName '.mat']) 9 | 10 | % generating example data: chirp 11 | samplingRate=1000; 12 | Time = 0:1/samplingRate:2; 13 | data = chirp(Time,100,1,200,'q'); 14 | figure; 15 | spectrogram(data,128,120,128,1E3,'yaxis') 16 | title('Quadratic chirp') 17 | 18 | %% Create video object and Initialize parameters 19 | vidObj = VideoWriter([fileName '.avi']); 20 | vidObj.FrameRate=25; 21 | open(vidObj); 22 | 23 | %% add frames 24 | set(0,'DefaultAxesColor','black') 25 | figure('Color','black','Visible', 'off'); 26 | for framNum=1:vidObj.FrameRate*10 %10 secondes 27 | %add an image to the movie: 28 | % f = im2frame(Img); 29 | % writeVideo(aviobj,f); 30 | 31 | %Or plot vector, then Add to Movie: 32 | plot(data((samplingRate/vidObj.FrameRate)*(framNum-1)+1:(samplingRate/vidObj.FrameRate)*(framNum)+1)); 33 | ylim([min(data(1:samplingRate*10+1)) max(data(1:samplingRate*10+1))]); 34 | % axis('tight');box off; 35 | f = getframe; 36 | writeVideo(vidObj,f); 37 | end 38 | 39 | %% close movie 40 | close(vidObj); 41 | 42 | -------------------------------------------------------------------------------- /min_max_values.m: -------------------------------------------------------------------------------- 1 | function colIdx=min_max_values(values,option) 2 | if strcmp(option,'min') 3 | colIdx=arrayfun(@(row) find(values(row,:)==min(values(row,:)),1),1:size(values,1)); 4 | elseif strcmp(option,'max') 5 | colIdx=arrayfun(@(row) find(values(row,:)==max(values(row,:)),1),1:size(values,1)); 6 | end -------------------------------------------------------------------------------- /my_cc_circ_shift.m: -------------------------------------------------------------------------------- 1 | %Compute the cross covariance between x and y. 2 | % 3 | %INPUT 4 | % x = signal #1. 5 | % y = signal #2. 6 | % 7 | %OUTPUT 8 | % rxy = the cross covariance between x and y. 9 | % lag = the lag axis, useful for plotting. 10 | 11 | function [rxy, lag] = my_cc_circ_shift(x,y) 12 | 13 | N = length(x); %The size of the data. 14 | rxyP = zeros(1,N-1); %The cross covariance at positive shifts. 15 | rxyN = zeros(1,N-1); %The cross covariance at negative shifts. 16 | lagP = zeros(1,N-1); %Lag axis for positive shifts. 17 | lagN = zeros(1,N-1); %Lag axis for negative shifts. 18 | 19 | for h=1:N-1 %Positive shifts. 20 | temp = sum(circshift(x,[1,h]).*y); 21 | rxyP(h)=temp; 22 | lagP(h)=h; 23 | end 24 | 25 | for h=1:N-1 %Negative shifts. 26 | temp = sum(circshift(x,[1,-h]).*y); 27 | rxyN(N-1-(h-1))=temp; 28 | lagN(N-1-(h-1))=-h; 29 | end 30 | 31 | temp = sum(x.*y); %Zero shift. 32 | rxy0 = temp; 33 | 34 | rxy = [rxyN rxy0 rxyP]/N; %Organize the results for output. 35 | lag = [lagN 0 lagP]; 36 | 37 | end -------------------------------------------------------------------------------- /nonhomopp.m: -------------------------------------------------------------------------------- 1 | function x=nonhomopp(intens,T) 2 | %generate a nonhomogeneousl poisson process on [0,T] with intensity function intens 3 | % e.g. t=7+nonhomopp('100-10*',5) 4 | x=0:.1:T; 5 | l=eval([intens 'x']); 6 | lam0=max(l); % this is used to generate homogeneouos poisson process 7 | u=rand(1,ceil(1.5*T*lam0)); 8 | x=cumsum(-(1/lam0)*log(u)); %points of homogeneous pp 9 | x=x(x