GithubHelp home page GithubHelp logo

skjerns / 3dprintedbrain_docker Goto Github PK

View Code? Open in Web Editor NEW

This project forked from miykael/3dprintyourbrain

16.0 4.0 2.0 4.93 MB

3D print your brain from a T1 MRI image using Docker.

License: BSD 3-Clause "New" or "Revised" License

Shell 66.32% Dockerfile 10.34% Python 23.34%
3d-printing docker mri t1

3dprintedbrain_docker's Introduction

2021-09-11 10.44.37.jpg

3D print your brain using Docker

A Docker image to create readily 3D-printable brains from T1 MRI scans. Just build the Docker image and run a command with your NIFTI file get a readily reconstructed STL mesh for 3D printing. This is an updated & extended version of miykael/3dprintyourbrain.

The actual process is as simple as running these two commands

docker build --tag 3dprintedbrain .
docker run -it -v ./:/opt/share 3dprintedbrain subject.nii

Prerequisites:

  • Docker client installed
  • Freesurfer license (it's free)
  • T1 MRI of your brain in NIFTI format (.nii or .nii.gz)

Instructions

1. Install Docker

Follow the instructions here to install Docker for your system (if not already installed). It is available for all major operating system.

2. Clone the repository and build docker image

Clone this repository by running

git clone [email protected]:skjerns/3dprintedbrain_docker.git

Then put your freesurfer license in the cloned repository. You can get the license.txt for free at FreeSurfer Registration form.

Navigate into the newly cloned repository and build the docker image by running the following command.

docker build --tag 3dprintedbrain .

3. Run extraction step

Put your subject.nii or subject.nii.gz file into the cloned repository. If your data is in DICOM format, you can easily convert it using the provided dcm2niigui.exe or dcm2niix or any other tool. NIFTI files contain all the brain data of a participant in one file.

Now simply run

docker run -it -v ./:/opt/share 3dprintedbrain subject.nii

This will run the script that automatically runs recon-all and extracts the brain structures, then smoothes them and puts them into one subject.stl. This process will take a couple of hours usually.

As a final result, there should be a subject.stl in your cloned repository folder which you can 3D print!

If you do not want to apply smoothing or decimation of vertices and want the raw output, simply call

docker run -it -v ./:/opt/share 3dprintedbrain subject.nii --smooth 0 --decimate 0

Using these two parameters, you can indicate the amount the cerebellum is smoothed and the number of target vertices (e.g. TinkerCAD only accepts <300.000 vertices, which is the scripts default), or a percentage (e.g. 0.5 to decimate half the vertices). Smoothing the cerebellum is highly recommended as it is very blocky/pixelated.

4. Connect the brain to the stand.stl

2021-09-11 09.13.41.jpg

I use small metal rods to connect the stand and the brain. Just find one in your local DIY store, 2mm is good. For a beginning you can also sacrifice a fork and break off a fork tine and use that as a connector. Then you can either drill holes for connection or model them directly into the 3D model. Just connecting it via PLA (3D print) will not work, as it's not stable enough. Neither can you print the entire thing at once, you need to print the stand and brain separately for stability.

For modelling and adaptations I use http://tinkercad.com, else Meshlab or Blender also work fine but are a bit more complex. Using these tools you can easily pre-model the hole that you want to use to connect the stand to the brain.

Here's a video tutorial how to connect the stand to the brain using a 2x2x30 mm metal rod

IMAGE ALT TEXT HERE

5. Print the stand and brain

So far I printed everything using http://treatstock.co.uk at 45% size, which is also the ratio the stand will fit nicely. Most brains will be around 7-8cm length when using 45% scaling. Cost for printing ranged from 10-30โ‚ฌ, depending on the color and material (ie. wood is more expensive than PLA, so is translucent or glow-in-the-dark PLA. Cheapest is probably always gray or silver.)

If you have further questions, feel free to open an issue. Connecting the stand to the brain is the most fidgety of all the steps in the guide and requires some trying out yourself.

Q&A

  1. I'm getting the error COPY failed: file not found in build context or excluded by .dockerignore: stat license.txt: file does not exist?

  2. My file is ending in .nii.gz , how do I get the .nii file?

    • you can simply use the .nii.gz file, no problem. it's just a zipped format of the .nii
  3. I don't want the mesh to be decimated that much / smoothed that much, I want the raw brain as it is reconstructed!

    • you can use the parameters --smooth X and --decimate X to indicate the number of smoothing steps and the target number of vertices or the percentage of decimation when calling the run command
  4. Wasn't there a version using WSL2 for windfows?The previous version of this README using WSL2 for Windows can be found here

3dprintedbrain_docker's People

Contributors

brandstaetter avatar jokedurnez avatar miykael avatar pezmc avatar skjerns avatar sofievdbos avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

yoursurname whkr

3dprintedbrain_docker's Issues

Cannot prepare internal mirrorlist: No URLs in mirrorlist

Hi,

While building the Dockerfile I'm having the following error:

docker build --tag 3dprintedbrain .

Sending build context to Docker daemon  8.729MB
Step 1/10 : FROM freesurfer/freesurfer:7.4.1
 ---> f5c26070586e
Step 2/10 : COPY ./create_3d_brain_docker.sh /opt/create_3d_brain_docker.sh
 ---> Using cache
 ---> 7a119c80464b
Step 3/10 : COPY ./post_process_mesh.py /opt/post_process_mesh.py
 ---> Using cache
 ---> e6e4687aad23
Step 4/10 : COPY ./license.txt /usr/local/freesurfer/license.txt
 ---> Using cache
 ---> 5bd1748a19ce
Step 5/10 : RUN yum install -y python3-pip
 ---> Running in 8507a32298d2
CentOS Stream 8 - AppStream                     113  B/s |  38  B     00:00    
Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist
The command '/bin/sh -c yum install -y python3-pip' returned a non-zero code: 1

Can you have a look at this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.