Wow Linux on Windows became essay WSL — Windows Subsystem for Linux !
How to run python libraries on Windows in Linux shell. Useful to Data scientists who need computational libraries as SimpleITK, that don’t work correctly on Windows.
My work is to design and build Deep Learning Neural Networks for Biomedical data segmentation. Unfortunately from some reasons, I found myself working on windows. Few years ago it was almost impossible, all deep learning libraries, where not supported on Windows. Today its much better, Keras and Tensorflow work well in windows environment. But still many specific Biomedical libraries, cause big problems on Windows.
After wasting a day trying to run N4BiasFieldCorrection on Windows ( N4BiasFieldCorrection is needed in almost any MRI analyzing software), I started to look for Linux on windows solution. I found this brilliant option, Windows Subsystem for Linux (WSL). It allows painless, seamless Linux installation on windows. And you can even invoke native Windows binaries from the Linux console and Linux binaries from a Windows console.
How To install:
- In Windows Features, turn on the “Windows Subsystem for Linux” .
- Restart
- From Microsoft Store, Get the app “Linux”.
- Choose your Favorited Linux, I chose Ubuntu, and click “Get”.
For detailed instalation instructions look here: https://www.howtogeek.com/249966/how-to-install-and-use-the-linux-bash-shell-on-windows-10/ and here: https://docs.microsoft.com/en-us/windows/wsl/install-win10
Now you have Linux shell up and ready on our windows. To access files from Linux, in drive “C” for example, just do:
cd /
cd /mnt/c
You might have permission Issues, since I am the only user of my computer, from window file explorer, I gave full access to everyone, and that solved all permission issues.
From windows CMD, you can run any Linux command using wsl.exe:
wsl ls -l
Now you can install Anaconda, or any other package and start using Linux. I installed miniconda3 from here: https://conda.io/miniconda.html, I installed simpleITK from anaconda.org:
conda install -c simpleitk simpleitk
And I could run SimpleITK N4BiasFieldCorrection, like the following:
inputImage = sitk.ReadImage( im_input )
inputImage = sitk.Cast( inputImage, sitk.sitkFloat32 )
maskImage = sitk.OtsuThreshold( inputImage, 0, 1, 200 )corrector = sitk.N4BiasFieldCorrectionImageFilter();
out_im = corrector.Execute( inputImage, maskImage )