connectomicslab / connectomemapper3

Connectome Mapper 3 is a BIDS App that implements full anatomical, diffusion, resting/state functional MRI, and recently EEG processing pipelines, from raw T1 / DWI / BOLD , and preprocessed EEG data to multi-resolution brain parcellation with corresponding connection matrices.
https://connectome-mapper-3.readthedocs.io
Other
71 stars 29 forks source link

Adapting Connectomemapper for Windows 10 #220

Open IsottaR opened 2 years ago

IsottaR commented 2 years ago

In principle the CMP works for Windows but there are problems concerning:

1) update user documentation to install CMP on Windows

2) CMP commandline docker integration 2.1 os.geteuid needs to be manually set to your machine ID (os.geteuid does not exsist for Windows)

3) CMPbidsapp manager 3.1 installation of cmp GUI 3.2 rendering of images in GUI 3.3 cmp command line does not run in interactive mode (docker -it)

jwirsich commented 2 years ago

Workaround for 3.2 (Images of Button cannot be loaded):

Drop

(border-image: url({image}) 0 0 0 0;)

in util.py in function return_button_style_sheet

Buttons will be replaced with Text of the Item name which works also with Win10.

Edit: Final solution: Enforce Posix Path Format of background color URL

border-image: url({Path(image).as_posix()}) 0 0 0 0;)

IsottaR commented 2 years ago

2.1 OS.GETEUID DOES NOT EXIST FOR WINDOWS To use CMP from command line: In cmp/cli/connectomemapper3_docker.py, substitute line 56 (cmd += '-u $(id -u):$(id -g) ') with: cmd += '-u 1000:1000'

To use the GUI: In bidsappmanager/gui/bidsapp.py, substitute line 820 (cmd.append(f"{os.geteuid()}:{os.getegid()}") with: cmd.append("1000:1000")

(1000 seems to be a common ID. Doublecheck the ID of your machine typing id in WSL terminal)

3.1 INSTALLATION OF CMP GUI

Download Anaconda for Windows:

Create the conda environment (modified from https://raw.githubusercontent.com/connectomicslab/connectomemapper3/master/conda/environment.yml) using the CMPenvironment.txt file (convert it into .yml) : CMPenvironment.txt conda env create -f path2downloaded_env\CMPenvironment.yml

Activate the environment: conda activate py39cmp-gui

Manually install the following:

pip install nibabel==3.2.2 –user
pip install matplotlib==3.5.2 nipype==1.8.0 traitsui==7.2.0 duecredit==0.9.1 mne==0.24.1 mne_connectivity==0.3 datalad[full]==0.17.2 datalad-container==1.1.6 datalad-neuroimaging==0.3.1 pybids==0.14.0 statsmodels==0.13.1 networkx==2.6.3 pydicom==2.2.2 pycartool==0.1.1
pip install obspy

Manually install MRtrix via: https://www.mrtrix.org/download/windows-msys2/

Manually install git-annex via: https://git-annex.branchable.com/install/Windows/ (download .exe file)

Install the cmp : pip install connectomemapper

3.3 CMP COMMAND LINE NOT RUNNING IN INTERACTIVE MODE

In bidsappmanager/gui/bidsapp.py, substitute line 799 ("docker", "run", "-it", "--rm") with: "docker", "run", "-i", "--rm"

jwirsich commented 1 year ago

2.1 OS.GETEUID DOES NOT EXIST FOR WINDOWS

'-u uid' option seems to be unecessary for the docker call, I propose to delete

IsottaR commented 1 year ago

To visualize results:

in cmtk/util.py, substitute line 422 (dict_outputs = json.loads("{}".format(str_outputs))) with: dict_outputs =fix_JSON("{}".format(str_outputs))

and add the function:

def fix_JSON(json_message=None):
    result = None
    try:
        result = json.loads(json_message)
    except Exception as e:
        indexs = [i for i, char in enumerate(json_message) if char == "\\"]

        temp = list(json_message)

        for idx in indexs:
            temp[idx] = '/'
        new_message = ''.join(temp)
        return fix_JSON(json_message=new_message)
    return result