Skip to content

Run resection identification using Docker container#920

Open
chinmaychinara91 wants to merge 12 commits into
brainstorm-tools:masterfrom
chinmaychinara91:auto-resec-container
Open

Run resection identification using Docker container#920
chinmaychinara91 wants to merge 12 commits into
brainstorm-tools:masterfrom
chinmaychinara91:auto-resec-container

Conversation

@chinmaychinara91
Copy link
Copy Markdown
Member

@chinmaychinara91 chinmaychinara91 commented May 18, 2026

This PR introduces the execution of the resection-identification plugin by transitioning it to run within a Docker container, utilizing the recent container-based plugin support in Brainstorm (#899).

Related forum discussion: https://neuroimage.usc.edu/forums/t/automatic-resection-identification/56589/16

Usage

  • Open Docker Desktop and keep it running in the background. Refer to the Notes section in the forum post above for some additional recommended setup.
  • Install the Anatomy > resection-identification plugin in Brainstorm to load the image and start the container.
  • Follow steps as mentioned in the tutorial (https://neuroimage.usc.edu/brainstorm/Tutorials/ResectionIdentification)

Checklist

  • Test on Windows 11 (w/ and w/o NVIDIA GPU)
  • Test on Mac (Apple Silicon) - needs more testing (see discussion - kept for future PR)
  • Test on Linux (w/ and w/o NVIDIA GPU)
  • Update tutorial page with info on the containerization

FYI: @tmedani @ajoshiusc @Edouard2laire

Extend `RunContainer` to accept isGpu and containerArgs parameters (with defaults) so callers can request GPU access and pass additional docker arguments
Useful when the MATLAB function errors or there is some user interrupt (e.g. Ctrl+C)
When GetEngine searches for engine binaries, prepend common macOS Docker locations to PATH (/usr/local/bin, ~/.docker/bin, /Applications/Docker.app/Contents/Resources/bin) so the subsequent 'which' call can locate Docker-related executables. This improves engine detection on macOS systems.
Copy link
Copy Markdown
Member Author

@chinmaychinara91 chinmaychinara91 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rcassani I have tested these for Windows and Mac (Apple Silicon) and it works fine. Would need you help on testing it on Linux.

Comment thread toolbox/core/bst_containers.m Outdated
@chinmaychinara91 chinmaychinara91 marked this pull request as ready for review May 18, 2026 23:29
Comment thread toolbox/core/bst_containers.m Outdated
Comment thread toolbox/core/bst_plugin.m Outdated
@rcassani
Copy link
Copy Markdown
Member

@chinmaychinara91, did you notice any strange behaviour on using the bst_containers API to handle the images and containers in Apple Silicon.

Specifically, in some tests @Edouard2laire reported the image SHA returned by ImportImage() did not match the image SHA obtained with GetImages() so Brainstorm was not able to check if the image was properly pulled. Check this PR: #917

FYI @Edouard2laire

@chinmaychinara91
Copy link
Copy Markdown
Member Author

@chinmaychinara91, did you notice any strange behaviour on using the bst_containers API to handle the images and containers in Apple Silicon.

Specifically, in some tests @Edouard2laire reported the image SHA returned by ImportImage() did not match the image SHA obtained with GetImages() so Brainstorm was not able to check if the image was properly pulled. Check this PR: #917

It works fine as it is now on Apple Silicon. On pulling, the correct image SHA is obtained. Nothing strange was observed there.

@chinmaychinara91
Copy link
Copy Markdown
Member Author

@Edouard2laire was it a specific scenario where you could not get the correct image SHA ?

@Edouard2laire
Copy link
Copy Markdown
Collaborator

Edouard2laire commented May 19, 2026

@Edouard2laire was it a specific scenario where you could not get the correct image SHA ?

I just tried with the example image,

and got this:

image

with the following plugin:

{
  "Name": "cont_plug",
  "Version": "latest",
  "URLzip": "",
  "URLinfo": "https://github.com/rcassani/bst-plugin-container",
  "ImageSource": "docker.io/library/alpine:latest",
  "CompiledStatus": 1,
  "Category": "User defined"
}

But the image is downloaded, just with a different sha:

[errMsg, imageList]     = bst_containers('GetImages')
{'alpine:latest'}    {'sha256:2ffb2ff4aab36d06…'}

docker pull returns this:

cmdout =

    'latest: Pulling from library/alpine
     Digest: sha256:5b10f432ef3da1b8d4c7eb6c487f2f5a8f096bc91145e68878dd4a5019afde11
     Status: Image is up to date for alpine:latest
     docker.io/library/alpine:latest
     '
image

I am using Matlab 2023b; Here are the info of docker:

image

@chinmaychinara91
Copy link
Copy Markdown
Member Author

These are from the Apple Silicon machine we have for the same cont_plug.json file. Image SHA looks fine across.

On MATLAB 2024b:
Screenshot 2026-05-19 at 4 12 28 PM

Docker desktop details:
Screenshot 2026-05-19 at 4 11 28 PM
Screenshot 2026-05-19 at 4 09 06 PM

@Edouard2laire
Copy link
Copy Markdown
Collaborator

Edouard2laire commented May 19, 2026

It seems, on my side that the digest is different form the imageID:

[edelaire1@home-imglab01:~]$ docker pull docker.io/library/alpine:latest
latest: Pulling from library/alpine
Digest: sha256:5b10f432ef3da1b8d4c7eb6c487f2f5a8f096bc91145e68878dd4a5019afde11
Status: Image is up to date for alpine:latest
docker.io/library/alpine:latest
[edelaire1@home-imglab01:~]$ docker image ls
REPOSITORY   TAG       IMAGE ID       CREATED       SIZE
alpine       latest    2ffb2ff4aab3   4 weeks ago   8.7MB
[edelaire1@home-imglab01:~]$ docker inspect alpine:latest --format='{{index .RepoDigests 0}}'
alpine@sha256:5b10f432ef3da1b8d4c7eb6c487f2f5a8f096bc91145e68878dd4a5019afde11

It seems to be discussed here: https://stackoverflow.com/questions/56364643/whats-the-difference-between-a-docker-images-image-id-and-its-digest

With docker image ls --digests , we can get the link between the two ids:

[edelaire1@home-imglab01:~]$ docker image ls --digests
REPOSITORY   TAG       DIGEST                                                                    IMAGE ID       CREATED       SIZE
alpine       latest    sha256:5b10f432ef3da1b8d4c7eb6c487f2f5a8f096bc91145e68878dd4a5019afde11   2ffb2ff4aab3   4 weeks ago   8.7MB

@chinmaychinara91
Copy link
Copy Markdown
Member Author

@rcassani just wanted to gently follow up on the next steps for this PR. Kindly let me know how you would like to proceed.

@rcassani
Copy link
Copy Markdown
Member

rcassani commented May 28, 2026

@chinmaychinara91,

  1. Please resolve the three requested changes:

https://github.com/brainstorm-tools/brainstorm3/pull/920/changes/BASE..a43ae27c42c19f3d583fb54e938c50b1241e9542

  1. I'll test on Linux with and without GPU, then it should be good to be merged

@chinmaychinara91
Copy link
Copy Markdown
Member Author

@rcassani I resolved the requested changes.

One thing I noticed: this error message appears in the command window:
BST> Error: Could not get online version for plugin: resection-identification

It looks like bst_plugin may need a few additional checks for container-based plugins, for example handling the call to GetVersionOnline when the plugin is a container. Since this is not directly in scope for this PR, maybe you could add those changes directly to master.

I'll test on Linux with and without GPU, then it should be good to be merged

Sounds good. I will update the tutorial as well once you give a go ahead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants