Open jcohenadad opened 4 years ago
I've drawn up my current understanding of where this fits in. The overall goal is to tune an MRI to get better resolution(?)/accuracy(?)/variance(?) in the images taken.
At the high level, first, a calibration scan is done and some tunings computed (per-subject!/per-session!), then those tunings are fed into the real experimental/clinical scan.
In the details, there are several different kinds of images we can take (2d slices, 3d, 3d video, maybe 2d-slice-video?), different tuning methods ("pulse sequence programming" or shim coils -- and different models of coils at that), and different kinds of scanners (though we've agreed to only treat with a specific Siemens model for the MVP).
This leaves out a lot of pieces, some features (e.g. video mode?) and has gaps where my understanding falls short.
Here's the code, full of plenty of ugly but functional typos:
flowchart TD
subgraph Realtime Shimming
calib1-->calib2-->calib3
subgraph Calibration
subgraph calib1[Record MR images]
1_a[Welcome subject to lab]-->
1_b[Place subject in MRI scanner]
-->1_c[Wait for subject to settle]
-->1_d
subgraph 1_d[Acquire images]
1_d_1{Scan type}
1_d_1-->|3d| cjdhis[Acquire 3d image]
1_d_1-->|3d| diofjsdofj[Acquire 2d slices]
end
1_d-->1_e[Export .dcm fies from MRI machine to processing computer]
end
subgraph calib2[Compute magnetic field map]
calib2_a[Load .dcm images]
-->calibr_b[Construct complex-valued images by concatenating magnitiude+phase]
-->calib2_c[Unwrap phase distortions]
-->dsfds[Compute fieldmap]
-->casdfsfds[Output fieldmap]
end
subgraph calib3[Generate calibration data]
calib3_0[Compensation Methods]
calib3_0 --> calib3_a
calib3_0 --> calib3_c
calib3_a{Pulse-Sequence?}--Yes-->b[Output pulse-sequence config file for Eva's code]
calib3_c{Noise-cancelling coil?}--Yes-->d[Optimize shim coefficients]-->e[Output coil calibration coefficients]
end
end
subgraph Scanning
s0[Place subject in MRI scanner]
s0-->s1
subgraph s1[Set up Compensation Methods]
s11{Pulse-sequence?}
-->|Yes| s111[Upload pulse-sequence config file to MRI interface computer]
--> s112[Command MRI to download pulse-sequence config file]
s12{Noise-cancelling coil?}
-->|Yes| s121[Place coil near subject]
--> s122[Connect arduino control mechanism to coil]
--> s123[Connect computer to arduino]
--> s124[Start serial port daemon process]
--> s125[Load optimized coil coefficients into coil controller]
end
s1-->s2
subgraph s2[Acquire images]
s21{Scan type}
s21-->|3d| s211[Acquire 3d image]
s21-->|2d| s212[Acquire 2d slices]
end
s2-->s3
subgraph s3[Apply compensation]
isduhfisu[????]
end
s3-->s4[Display images]
end
Calibration -- Calibration data --> Scanning
end
You can edit this diagram here to make it more accurate.
Editorializing: I did this in mermaid and the result is pretty nice and I like where they're going with it but after working with it for a couple hours I think I would rather just use graphviz. Mermaid still has lots of quirks and bugs to iron out, and it's pretty slow to work with because its only implementation must run through javascript in a web browser. Visio or Inkscape are good GUI alternatives (Inkscape is especially nice in that it works on .svgs, in fact it is the defacto world svg editor, the same format Mermaid generates).
btw, @rtopfer, with regard to refactoring, every 'or' I mentioned above could nicely become an abstract base class. That way the two parts of the process don't need to explicitly communicate which kind they're sending around.
(and please edit my diagram. I know it's wrong. You know how it should look)
Very nice! I made some minor edits: the "noise-cancelling coil" can be called a shim coil. The "pulse-sequence" compensation method can only compensate 2D images, so I removed the 2d/3d portion. There is no manual step for applying the compensation, the sequence takes care of it when you provide that config. file, same thing for the shim coil (someone else can confirm that though). I tried to modify the field map portion (to describe the 2 options that are implemented in the code: B0 maps from Siemens' sequence or using a dual-echo gre) but I wasn't able to make it work!
@evaalonsoortiz The link shared by Nick does not seem to reflect the changes you made, maybe the link changes according to the edits.
Thank you so much for this initial flowchart @kousu ! As the overall organization (processes, sub-processes, etc.) and their interaction is still under scrutiny, it might be easier for the team to start with a GUI. Let's try draw.io, as it also enables version-tracked embedding (good for our doc)-- we might come back to mermaid or graphiz once we settle on a general overview.
Alexandre and I started a preliminary version on draw.io, which includes a modified version of your flowchart. We will share within this thread asap, so everyone can edit.
@evaalonsoortiz The link shared by Nick does not seem to reflect the changes you made, maybe the link changes according to the edits.
It does! The URL includes the entire source code ((it's base64-json-encoded)). If you click "Download PNG" you can attach the new version here, along with the updated link, @evaalonsoortiz.
But draw.io is good too!
@evaalonsoortiz The link shared by Nick does not seem to reflect the changes you made, maybe the link changes according to the edits.
It does! The URL includes the entire source code ((it's base64-json-encoded)). If you click "Download PNG" you can attach the new version here, along with the updated link, @evaalonsoortiz.
Oh no, I lost it then! I will revisit once it's moved to draw.io
@evaalonsoortiz The link shared by Nick does not seem to reflect the changes you made, maybe the link changes according to the edits.
It does! The URL includes the entire source code ((it's base64-json-encoded)). If you click "Download PNG" you can attach the new version here, along with the updated link, @evaalonsoortiz.
Oh no, I lost it then! I will revisit once it's moved to draw.io
Oh no!
It might still be in your browser history?
Yes, it's here.
Thanks Eva! Here's a snapshot of it:
Thanks for posting. I will expand the 2 options for B0 mapping once we move to another platform.
Thanks for posting. I will expand the 2 options for B0 mapping once we move to another platform.
Hi Eva, we started something here: https://app.diagrams.net/#G1BqYuqOvTUyPTHhb3z19rktEv6lZU3ehM
Do I need special permissions to access?
I checked and you should have access. It's in the acdc-code drive.
This flowchart will eventually turn into a user manual, complete with diagrams and photos of the experimental set up, and several matlab commands. Following that manual should let someone (in my opinion, without being a trained MRI technician) perform an experiment.
In order to get there, it's important that the flowchart pays special attention to what data is passed between what component and when and what its format is. In my experience 90% of implementation work is arranging data transport (serial, TCP, SSH, NFS, REST, the list is long) and translating data formats. By format I mean:
I wish we could notate the data transports too.
90% of the implementation work in this kind of project is making sure the data interchange goes smoothly.
As we are refactoring shimming-toolbox, it would be helpful to have an overview of the different processes and how they relate to each other. Notably, knowing the inputs/outputs will help us in the refactoring task.
This (or these) flowcharts should ideally cover all the possible scenario that we would like shimming-toolbox to cover.
Here is a link to the flowchart (click "open with diagrams.net", only editable for members of shimming-toolbox googlegroup): https://drive.google.com/file/d/1BqYuqOvTUyPTHhb3z19rktEv6lZU3ehM/view?usp=sharing