This page will take you through setting up MountainSort on your WSL. These set of instructions follow the directions provided on the GitHub1 page for MountainSort so feel free to follow their instructions instead as this post was written on May 1st, 2019.
Table of Contents
Install Conda
The documentation suggests using conda to install MountainSort, so lets not go against the grain here. I am not the biggest fan of conda to begin with as it generally creates some awkward conflicts with my other Python installations. However, this instance of conda should be isolated to WSL and thus should not create too many conflicts.
- First we will to launch WSL by typing the following command into the Windows command prompt:
ubuntu # or use version if necessary, example for the Ubuntu 18.04 app ubuntu1804
- Download conda for the WSL by using the following command in the Ubuntu terminal:
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda3.sh
- Now we will batch install conda to the ~/conda directory with the following Ubuntu command:
bash miniconda3.sh -bp ~/conda
- Next we will initialize conda, this command will export the conda
$path
as an environment variable by adding it to the ~/.bashrc file:
conda init
- You might receive the following response due to the
conda init
command: conda: command not found. If so, you will need to add the conda$path
manually with the following command:
Now if you redo theexport PATH=~/conda/bin:$PATH
conda init
command you should be able to successfully setup conda.
- You might receive the following response due to the
- It will likely ask that you re-open the shell. So re-launch the WSL.
- When you launch it might have activated a sample environment called base. You know an environment is active if the terminal says the name of an environment in parentheses before the username@computer_name, an example is pictured below:
- If this environment is not activated, activate it by typing the following command:
conda activate base
- If this environment is not activated, activate it by typing the following command:
- Update the conda base environment with the following command:
conda update conda
- Create an environment for MountainLab/MountainSort, we will call our environment mlab:
conda create -n mlab
- You will likely have you confirm your environment location.
- Now we are going to add a line to the ~/.bashrc file that will allow us to automatically activate our mlab environment when we start the WSL.
- open the ~/.bashrc file by typing the following command:
sudo nano ~/.bashrc
- You will likely have to provide your password due to it being a sudo command.
- Scroll all the way to the bottom of the ~/.bashrc file and add the following line:
conda activate mlab
- Type Ctrl+X to exit, then press Y key to save the changes, followed by Enter to confirm.
- Now if you close and re-open the WSL, you will see that the mlab environment is active.
- open the ~/.bashrc file by typing the following command:
MountainSort Installation
- Ensure that your mlab environment is active (or whatever you called the environment) with the use of
conda activate environment_name
. - Now we can install the appropriate MountainLab and MountainSort packages with the following command:
conda install -c flatiron -c conda-forge \ mountainlab \ mountainlab_pytools \ ml_ephys \ ml_ms3 \ ml_ms4alg \ ml_pyms
- You will likely have to continue confirming the installation by pressing the Y key.
- At a later date, if you wanted to update the MountainSort and MountainLab packages you can use the following command:
conda update -c flatiron -c conda-forge \ mountainlab \ mountainlab_pytools \ ml_ephys \ ml_ms3 \ ml_ms4alg \ ml_pyms
- Test that the installations were successful with the following command:
ml-list-processors
You should see a list of processors that you can use within MountainSort similar to the image below.
MountainLab Configuration
Before being able to run MountainSort, we have to configure MountainLab properly. MountainLab will save temporary/intermediate files within a specified directory, but we need to specify which one to save it in. These directories will also have to belong to the same drive where the data is stored.
- Identify which drive you will be using for the analysis and note the letter. For example, the drive that Windows is installed on is generally called the "C:" drive, a secondary drive might be named "D:". In our case I will always be moving the data to the external D: drive.
- Create a directory in your chosen drive that will contain temporary files produced by Mountainsort/MountainLab. For example I will create the following directory:
D:\MountainSortTemp
- Now lets configure MountainSort by typing in the following command:
ml-config
- You want to modify the ML_TEMPORARY_DIRECTORY variable. These variables are stored and referenced in a mountainlab.env file within your mountainlab directory. In my example I have chosen the
D:\MountainSortTemp
directory. This Windows filepath is different within the WSL so we will have to convert our filename to the appropriate Ubuntu filename. All of the connected Windows drives have their corresponding letters mounted in the /mnt location (confirm by using thecd /mnt
command in the Ubuntu terminal).D:\MountainSortTemp
will correspond to/mnt/d/MountainSortTemp
in Ubuntu, this Ubuntu path is the one we need to use in the configuration.
- You want to modify the ML_TEMPORARY_DIRECTORY variable. These variables are stored and referenced in a mountainlab.env file within your mountainlab directory. In my example I have chosen the
- You will see the following response (to
ml-config
) stating the name of the config file (at the top), and the directory variables:
----------------------------------------------------------- No config file found at: /home/username/conda/envs/mlab/etc/mountainlab/mountainlab.env To change this, set either the ML_CONFIG_DIRECTORY or ML_CONFIG_FILE environment variable. The following environment variables are being used. They can be set in the configuration file (see above), although existing environment variables will not be overriden by configuration file entries. ML_TEMPORARY_DIRECTORY: [default] ML_PACKAGE_SEARCH_DIRECTORY: [default] ML_ADDITIONAL_PACKAGE_SEARCH_DIRECTORIES: [default] ML_ADDITIONAL_PRV_SEARCH_DIRECTORIES: [default] ML_DATABASE_DIRECTORY: [default] The following are the values actually being used: Temporary directory: /tmp/mountainlab-tmp Package search directories: /home/username/conda/envs/mlab/etc/mountainlab/packages:/home/username/conda/envs/mlab/lib/node_modules/mountainlab/system-packages PRV search directories: /tmp/mountainlab-tmp Database directory: /home/username/conda/envs/mlab/etc/mountainlab/database
- At the top of the response it says
No config file at /home/username/conda/envs/mlab/etc/mountainlab/mountainlab.env
therefore we must create it. If the file does exist, the response will state the followingUsing configuration from: /home/username/conda/envs/mlab/etc/mountainlab/mountainlab.env
. Either way, we will modify the ML_TEMPORARY_DIRECTORY variable by using the following command. Note: replace "username" with the appropriate username:
nano /home/username/conda/envs/mlab/etc/mountainlab/mountainlab.env
- If you are editing an existing file (that isn't blank), you should see existing text fields. You are looking for the line that says
ML_TEMPORARY_DIRECTORY=X
. You will replace the X value as shown below:
ML_TEMPORARY_DIRECTORY=/mnt/d/MountainSortTemp
- If the file is empty, just type the above text in the file.
- Save by pressing Ctrl+X, followed by Y, and then Enter.
- Now when we re-run the
ml-config
command the response should no longer say that the ML_TEMPORARY_DIRECTORY is set to [default].
- At the top of the response it says
Installing Data Visualization Packages
There are two ways to visualize the MountainSort'ed data (that the development team provides).
- The first package is ephys-viz, I personally have never used this package as it has been in development. I have attempted to use this package without any luck so I suggest moving onto the second option. If you wish to try ephys-viz, you can install it by using the following command:
conda install -c flatiron -c conda-forge ephys-viz
- The second package provided is MountainView, which was the legacy GUI used with the older versions of MountainSort. I tend to opt for using this over ephys-viz personally. However, I ultimately convert all the data from MountainSort to a format that I can use with other proprietary data visualization software. You can install MountainView with the use of the following command:
conda install -c flatiron -c conda-forge qt-mountainview
- I also suggest downloading Qt5. I had some errors attempting to use MountainView because I did not download Qt5. You can do so by using the following command:
sudo apt-get install qtdeclarative5-dev qt5-default qtbase5-dev qtscript5-dev make g++
- I received the following error when attempting to use MoutainView:
qt-mountainview: error while loading shared libraries: libGL.so.1: cannot open shared object file: No such file or directory
. Therefore, I also suggest you install the libraries using the following command:
sudo apt-get install libglu1-mesa
References
- MountainSort (JS version) Installation: https://github.com/flatironinstitute/mountainsort_examples/blob/master/README.md