jarosado0911 / PythonNeuronMeshes

This repository is generating neuron mesh geometries from 1d Neuromorpho.org geometries.
1 stars 0 forks source link
digraph digraphs geometry graphs mesh mesh-algorithms mesh-processing meshing neuron neuron-model neurons parallel-frame-transport parallel-transport python rendering unity virtual-reality

PythonNeuronMeshes

Contents

What?

This project takes a .swc file downloaded from NeuroMorpho.org and generates:

The code allows the user to use spline interpolation for regularizing/refining the geometry or the user can produce refinements on the original .swc file. Below is a figure showing refinments generated using spline interpolation from Python's module scipy, details on the specific function are found here: scipy.interpolate.

Size Limit CLI

The project uses Parallel Transport Frames to generate the contours used in the mesh generation. Below is a figure showing some meshes with increasing refinements. Wikipedia on parallel tranpsport.

Size Limit CLI

Below is a figure showing the 1d geometry centered within the 3d surface mesh geometry (triangular faces hidden).

Size Limit CLI

Installation

The project uses Python in particular I provide some version information that is currently used. I recommend using Jupyter-Notebooks and downloading Promesh4 for view the geometries. Other than that there is nothing else to install.

Python version:  3.8.10 (default, Mar 13 2023, 10:26:41)
[GCC 9.4.0]
Version info:    sys.version_info(major=3, minor=8, micro=10, releaselevel='final', serial=0)
Argparse:        1.1
networkx:        3.1
scipy:           1.10.1
numpy:           1.24.3
maplotlib:       3.7.1
JSON:            2.0.9

This code was developed on a Windows Machine using Windows Subsystem for Linux (WSL) below are the computer specs:

Host Name:                 DESKTOP-R1UGLGT
OS Name:                   Microsoft Windows 11 Home
OS Version:                10.0.22621 N/A Build 22621
OS Manufacturer:           Microsoft Corporation
OS Configuration:          Standalone Workstation
OS Build Type:             Multiprocessor Free
System Manufacturer:       Alienware
System Model:              Alienware m15 R4
System Type:               x64-based PC
Processor(s):              1 Processor(s) Installed.
                           [01]: Intel64 Family 6 Model 165 Stepping 2 GenuineIntel ~2208 Mhz
BIOS Version:              Alienware 1.17.0, 3/14/2023
Windows Directory:         C:\WINDOWS
System Directory:          C:\WINDOWS\system32
Boot Device:               \Device\HarddiskVolume1
System Locale:             en-us;English (United States)
Input Locale:              en-us;English (United States)

Here is WSL information

 NAME      STATE           VERSION
* Ubuntu    Running         2

Welcome to Ubuntu 20.04.2 LTS (GNU/Linux 5.4.72-microsoft-standard-WSL2 x86_64)

If you are using Windows, then look here for a training module on WSL: Module-WSL

I also use Jupyter Notebooks when developing the code, I found it easy to work with and maneuver through the codes. In wsl I called

jupyter-notebook --allow-root --no-browser

and then select one of the links to copy and paste into a browser (Chrome worked for me). You can also try using VSCODE I haven't use this, but it should work just as well

Project Contents

When you git clone or download this project you should have the following items:

Usage

This usage example was done on wsl, it 'should' work on Linux terminal as well (pending you have all the correct version of python and modules). I will try to include directions for PowerShell and GitBash.

There is a file called NEW_generate_meshes.py if you execute in the commandline python3 NEW_generate_mesh.py you will receive the following output

usage: NEW_generate_meshes.py [-h] [-n NUMREFINE] [-d STARTDX] [-c NUMCONTPTS] [-p SPHERECONTOURS] [-q SPHEREPOINTS] -i INPUT
NEW_generate_meshes.py: error: the following arguments are required: -i/--input

If you execute python3 NEW_generate_meshes.py -h you will get some more help information:

usage: NEW_generate_meshes.py [-h] [-n NUMREFINE] [-d STARTDX] [-c NUMCONTPTS] [-p SPHERECONTOURS] [-q SPHEREPOINTS] -i INPUT

This program will generate .swc refinements, .ugx 1d refinements, and .ugx surface meshes and zip all files into a .vrn file,
usage: python3 NEW_generate_meshes.py -n 6 -c 6 -d 32.0 -p 10 -q 16 -i cells/<cellname>

optional arguments:
  -h, --help            show this help message and exit
  -n NUMREFINE, --numrefine NUMREFINE
                        Number of Refinements
  -d STARTDX, --startdx STARTDX
                        Largest DeltaX
  -c NUMCONTPTS, --numcontpts NUMCONTPTS
                        Number of Contour points
  -p SPHERECONTOURS, --spherecontours SPHERECONTOURS
                        Number of sphere contours
  -q SPHEREPOINTS, --spherepoints SPHEREPOINTS
                        Number of points per sphere contour
  -i INPUT, --input INPUT
                        The input .swc file

The folder cells contains cells which were downloaded from NeuroMorpho.org Example usage shown below

python3 NEW_generate_meshes.py -n 10 -c 10 -d 64.0 -p 16 -q 16 -i cells/Purkinje-slice-ageP43-6.CNG.swc

This will produce an output folder called <cell_name>.mesh and it will contain .swc files and .ugx files which are numbered accordingly. It will also produce a .vrn file to be used in NeuroVisor

The parameter c affects the type of regular polygon used for the contours, in the figure below the far left mesh uses 32-ngons for contours and the far right uses equilateral triangles (3-gons) for contours.

Size Limit CLI

Other

Tasks!

Here is a lists of tasks that need to be completed and questions that need to be answered

Size Limit CLI