User Tools

Site Tools


analysis:nsb2019:week1

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
analysis:nsb2019:week1 [2019/06/27 07:26]
amarek
analysis:nsb2019:week1 [2022/06/27 17:02] (current)
mvdm
Line 1: Line 1:
-~~DISCUSSION~~ 
- 
 ==== Module 1: Setting up ==== ==== Module 1: Setting up ====
  
Line 24: Line 22:
 At MBL, MATLAB should already be installed on lab computers. Verify it starts correctly; you should see its main window open up, including a panel called "​Command Window"​ greeting you with a prompt (''>>''​). At Dartmouth, follow [[https://​tech.dartmouth.edu/​itc/​services-support/​help-yourself/​knowledge-base/​matlab|these instructions]] to install MATLAB. Release 2018a seems to work. At MBL, MATLAB should already be installed on lab computers. Verify it starts correctly; you should see its main window open up, including a panel called "​Command Window"​ greeting you with a prompt (''>>''​). At Dartmouth, follow [[https://​tech.dartmouth.edu/​itc/​services-support/​help-yourself/​knowledge-base/​matlab|these instructions]] to install MATLAB. Release 2018a seems to work.
  
-=== Setting up GitHub ​===+=== Setting up Git ===
  
 Next, we need to obtain some existing MATLAB code that we will build on in this module. To do this, we will use [[http://​www.github.com|GitHub]]. Next, we need to obtain some existing MATLAB code that we will build on in this module. To do this, we will use [[http://​www.github.com|GitHub]].
Line 30: Line 28:
 %%GitHub%% is a system for "​distributed version control":​ it keeps track of changes to a set of files, such as pieces of MATLAB code, with one or more contributors. This system makes it easy to keep track of evolving code, and to share improvements between collaborators. Typical scenarios in which such version control is useful include, for instance, if you want to run the exact code that you used to generate some figure a while ago, but you've since made changes to the code; or the same analysis suddenly gives a different result and you want to track down what change caused it. If you are new to %%GitHub%%, you can watch the video under Resources above to get an overall idea of how it works and why it is useful. %%GitHub%% is a system for "​distributed version control":​ it keeps track of changes to a set of files, such as pieces of MATLAB code, with one or more contributors. This system makes it easy to keep track of evolving code, and to share improvements between collaborators. Typical scenarios in which such version control is useful include, for instance, if you want to run the exact code that you used to generate some figure a while ago, but you've since made changes to the code; or the same analysis suddenly gives a different result and you want to track down what change caused it. If you are new to %%GitHub%%, you can watch the video under Resources above to get an overall idea of how it works and why it is useful.
  
-For now, you can use the module %%GitHub%% account, see the ''​README.txt''​ file on the share for the credentials. You're also welcome to use your own account; if you don't have one yet, go to [[http://​www.github.com|GitHub]] and sign up. E-mail me (mvdm at dartmouth dot edu) your account name, so I can give you write access to the code repository we will use. +Meanwhile, download and install the Git client of your choice if you don't already have one installed. This is a piece of software that will allow you to talk to %%GitHub%%, which is where the code is actually stored. For Windows, ​you can get git [[https://git-scm.com/download/​win ​here]]. For more detailed info on different ​Git clients ​and setting up Git on other operating systems, see [[https://​help.github.com/​articles/​set-up-git|GitHub:​ Set Up Git]].
- +
-Meanwhile, download and install the Git client of your choice if you don't already have one installed. This is a piece of software that will allow you to talk to %%GitHub%%, which is where the code is actually stored. For Windows, ​I recommend ​[[https://github-windows.s3.amazonaws.com/GitHubSetup.exe|GitHub Desktop for Windows]] as a user-friendly way to get started. For installing ​Git and setting up GitHub ​on various ​operating systems, see [[https://​help.github.com/​articles/​set-up-git|GitHub:​ Set Up Git]]+
- +
-Next, configure your client. For %%GitHub%% Windows, after starting up the %%GitHub%% %%GUI%% (the default window that opens when you run %%GitHub%%) you'll first need to sign in with your account, then click Tools > Options. Set the "​Default Storage Directory"​ to something reasonable such as ''​D:​\My_Documents\GitHub\''​). Also check that your username and e-mail address look ok (I am ''​mvdm''​).+
  
 === Cloning the module codebase === === Cloning the module codebase ===
  
-Now we are ready to use Git to create a local copy ("​clone"​) of the module codebase. ​If this is your first time using gitI recommend you open a Git Shell, which you can do by typing ''​Git Shell''​ in the search box of the Start menu. Once open, note your working directory (displayed at the prompt of your now opened shell) and type ''​git clone https://​github.com/​mvdm/​nsb2018'',​ which will create a new folder ''​nsb2019''​ in your working directory.+Now we are ready to use Git to create a local copy ("​clone"​) of the module codebase. ​On Windows, open a PowerShell, which you can do by typing ''​PowerShell''​ in the search box of the Start menu. Once open, note your working directory (displayed at the prompt of your now opened shell)and change it to a different location if you prefer, using the ``cd`` command. Once you are in an appropriate location, such as a new folder named ''​GitHub''​ on your local machine, ​type ''​git clone https://​github.com/​mvdm/​nsb2022'',​ which will create a new folder ''​nsb2022''​ in your working directory.
  
-As an alternative,​ you can navigate to the course repository [[https://​github.com/​mvdm/​nsb2017|web page]] on %%GitHub%%. There, click the button "Clone in desktop",​ and your %%GitHub%% client should prompt you to accept the clone (tested successfully with Chrome, %%YMMV%%). If this fails, you can [[http://​joe.blog.freemansoft.com/​2014/​04/​github-clone-to-desktop-with-windows.html|drag]] the URL from your browser into your %%GitHub%% client. +Now, verify that the above steps have resulted in the creation of a ''​nsb2022''​ folder with various subfolders and files in it, indicating that you have a local copy of the codebase. Because Git is tracking the contents of this folder, it is now easy to "​pull"​ the latest version from %%GitHub%%:
- +
-Now, verify that the above steps have resulted in the creation of a ''​nsb2019''​ folder with various subfolders and files in it, indicating that you have a local copy of the codebase. Because Git is tracking the contents of this folder, it is now easy to "​pull"​ the latest version from %%GitHub%%, either from the command line (after you ''​cd''​ into the ''​nsb2019''​ folder):+
  
 <​code>​ <​code>​
 git pull git pull
 </​code>​ </​code>​
- 
-Or, by clicking the ''​Sync''​ button in the %%GUI%%. 
  
 This "​pull"​ should do nothing, because you already have the latest version. The basic idea is that you can stay up-to-date easily as well as contribute to the codebase so that everyone else can benefit. As you might expect, that part is known as a "​push",​ which we will do in the next step. This "​pull"​ should do nothing, because you already have the latest version. The basic idea is that you can stay up-to-date easily as well as contribute to the codebase so that everyone else can benefit. As you might expect, that part is known as a "​push",​ which we will do in the next step.
  
 === A first commit and push ===  === A first commit and push === 
 +
 +To complete this part, sign up for a [[http://​www.github.com|GitHub account]] if you don't already have one, and post your username in the module Slack channel so I can give you permission to write to the code repository.
  
 First, if you haven'​t "done a pull" recently, do one now before starting the next step. First, if you haven'​t "done a pull" recently, do one now before starting the next step.
  
-Open the ''​README.md''​ file in the ''​nsb2019''​ folder. The ''​.md''​ extension is for %%Markdown%%,​ a lightweight set of commands to format text (syntax reference is [[https://​help.github.com/​articles/​markdown-basics | here]]).+Open the ''​README.md''​ file in the ''​nsb2022''​ folder. The ''​.md''​ extension is for %%Markdown%%,​ a lightweight set of commands to format text (syntax reference is [[https://​help.github.com/​articles/​markdown-basics | here]]).
  
-Add your name, affiliation and a brief description of your interests ​to the list, and save the file. Then go to your git shell (open one with the gear icon in the top right of your client'​s %%GUI%%, or use the desktop icon) and type ''​git status''​. Git has noticed ​the change, but it says that this change is not yet "​staged for commit"​. In other words, git is not tracking this file. Let's fix this:+Add your name to the list, and save the file. Then navigate ​to the ''​nsb2022''​ repository ​in a shell and type ''​git status''​. Git should notice ​the change, but it says that this change is not yet "​staged for commit"​. In other words, git is not tracking this file. Let's fix this:
  
 <​code>​ <​code>​
Line 65: Line 57:
 </​code>​ </​code>​
  
-If you now do a ''​git status''​ you will see that you are ahead of the origin (the online repository) by 1 commit. This makes sense because you just made a change. Let's push this by doing ''​git push''​. If you get an "​access denied"​ type error, ​email me (mvdm at dartmouth dot eduyour %%GitHub%% username ​and I will give you permission. If everything goes to plan you should now be able to see the updated README file [[https://​github.com/​mvdm/​nsb2017| on GitHub]]. As above, you can also use the %%GUI%% ''​Sync''​ button to accomplish the same steps (albeit in a less transparent manner).+If you now do a ''​git status''​ you will see that you are ahead of the origin (the online repository) by 1 commit. This makes sense because you just made a change. Let's push this by doing ''​git push''​. If you get an "​access denied"​ type error, ​let me (mvdm) ​know and I will give you permission. If everything goes to plan you should now be able to see the updated README file [[https://​github.com/​mvdm/​nsb2022| on GitHub]].
  
 A schematic of these basic operations (pull, commit, push) is shown below, using the amazing [[https://​www.dokuwiki.org/​plugin:​graphviz|DokuWiki plugin]] for [[http://​www.graphviz.org/​|GraphViz]]:​ A schematic of these basic operations (pull, commit, push) is shown below, using the amazing [[https://​www.dokuwiki.org/​plugin:​graphviz|DokuWiki plugin]] for [[http://​www.graphviz.org/​|GraphViz]]:​
Line 81: Line 73:
 === Using GitHub to acquire the FieldTrip toolbox === === Using GitHub to acquire the FieldTrip toolbox ===
  
-Using your experience from the previous section, create a local clone of the [[https://​github.com/​fieldtrip/​fieldtrip|FieldTrip toolbox]]. If you are using the command line, make sure that you ''​cd''​ to your %%GitHub%% folder, i.e. that you are not within some other project such as ''​nsb2019'',​ before cloning. If things worked correctly you should have ''​fieldtrip''​ and ''​nsb2019''​ folders within your %%GitHub%% folder; **not** a ''​fieldtrip''​ folder within your ''​nsb2019''​ folder!+Using your experience from the previous section, create a local clone of the [[https://​github.com/​fieldtrip/​fieldtrip|FieldTrip toolbox]]. If you are using the command line (shell), make sure that you ''​cd''​ to your %%GitHub%% folder, i.e. that you are not within some other project such as ''​nsb2022'',​ before cloning. If things worked correctly you should have ''​fieldtrip''​ and ''​nsb2022''​ folders within your %%GitHub%% folder; **not** a ''​fieldtrip''​ folder within your ''​nsb2022''​ folder!
  
-We will use this toolbox ​extensively ​for the analysis of local field potential (LFP) data. Be aware that it is about 1.2GB in size!+This toolbox ​is useful ​for the analysis of local field potential (LFP) data. Be aware that it is about 1.2GB in size!
  
 Note how using %%GitHub%% to obtain %%FieldTrip%% not only ensures you have the most recent version, but also enables you to easily incorporate future changes, revert to previous versions, etc. using pull and other git tools. Note how using %%GitHub%% to obtain %%FieldTrip%% not only ensures you have the most recent version, but also enables you to easily incorporate future changes, revert to previous versions, etc. using pull and other git tools.
Line 94: Line 86:
 restoredefaultpath;​ clear classes; % start with a clean slate restoredefaultpath;​ clear classes; % start with a clean slate
  
-cd('​D:​\My_Documents\GitHub\nsb2019\code-matlab\shared'​);​ % or, wherever your code is located -- NOTE \shared subfolder!+cd('​D:​\My_Documents\GitHub\nsb2022\code-matlab\shared'​);​ % or, wherever your code is located -- NOTE \shared subfolder!
 p = genpath(pwd);​ % create list of all folders from here p = genpath(pwd);​ % create list of all folders from here
 addpath(p); addpath(p);
Line 106: Line 98:
 This ensures that whenever you click this button, you have a clean **path** (the set of folders, other than the current working directory, whose contents MATLAB can access) of only the MATLAB default plus your local versions of the two %%GitHub%% repositories. This ensures that whenever you click this button, you have a clean **path** (the set of folders, other than the current working directory, whose contents MATLAB can access) of only the MATLAB default plus your local versions of the two %%GitHub%% repositories.
  
-:!: When setting your path in MATLAB to add the ''​shared''​ folder only and //not// a parent folder such as ''​nsb2019''​. Adding the entire ''​nsb2019''​ folder will result in an error when you try to run the LoadCSC command later in the module!+:!: When setting your path in MATLAB to add the ''​shared''​ folder only and //not// a parent folder such as ''​nsb2022''​. Adding the entire ''​nsb2022''​ folder will result in an error when you try to run the LoadCSC command later in the module!
  
 Optional: if you don't like the ''​.git''​ folders in your path, you can get clever with [[http://​www.mathworks.com/​help/​matlab/​matlab_prog/​regular-expressions.html|regular expressions]] to remove these: Optional: if you don't like the ''​.git''​ folders in your path, you can get clever with [[http://​www.mathworks.com/​help/​matlab/​matlab_prog/​regular-expressions.html|regular expressions]] to remove these:
Line 134: Line 126:
 === Grab an example data session === === Grab an example data session ===
  
-Next, let's get some data! At MBL, go the NS&B share and find the ''​tutorial_data''​ folder (within the MouseStriatum ​folder). At Dartmouth or elsewhere, you'll need to connect to the lab server. E-mail MvdM for instructions on how to do that.+Next, let's get some data! At MBL, go the NS&B share and find the ''​tutorial_data''​ folder (within the MouseModule ​folder). At Dartmouth or elsewhere, you'll need to connect to the lab server. E-mail MvdM for instructions on how to do that.
  
 For this module you will need the ''​R016-2012-10-08''​ folder (containing data from one recording session), which you can find in the ''​\promoted\R016''​ folder on the share. Copy this folder onto your own computer. A good place to put it is in something like ''​D:​\data\promoted\''​ (Rxxx indicate different rats, followed by the date of each session). As mentioned, in general you want to keep your data separate from your code; for instance, multiple analysis projects may use the same data, so you don't want to duplicate it. For this module you will need the ''​R016-2012-10-08''​ folder (containing data from one recording session), which you can find in the ''​\promoted\R016''​ folder on the share. Copy this folder onto your own computer. A good place to put it is in something like ''​D:​\data\promoted\''​ (Rxxx indicate different rats, followed by the date of each session). As mentioned, in general you want to keep your data separate from your code; for instance, multiple analysis projects may use the same data, so you don't want to duplicate it.
analysis/nsb2019/week1.1561634764.txt.gz · Last modified: 2019/06/27 07:26 by amarek