korbinian90 / CLEARSWI.jl

improved susceptibility weighted imaging using multi-echo aquisitions
https://korbinian90.github.io/CLEARSWI.jl/dev
MIT License
27 stars 11 forks source link

standalone version of CLEARSWI #7

Closed stebo85 closed 2 years ago

stebo85 commented 2 years ago

Dear Korbinian,

Would it be useful for users to have a versioned standalone version of CLEARSWI as well like you did with ROMEO?

Cheers Steffen

korbinian90 commented 2 years ago

Hi Steffen,

I'm not sure about the benefit, as I received the feedback that it works nicely in julia. However I plan to build a standalone version anyway to use it within SEPIA.

But since you ask, I guess it would be useful for users ;)

stebo85 commented 2 years ago

oh, cool :) Yes, I think it would be great to run it as a standard binary, then users who are not familiar with julia yet don't get lost :)

korbinian90 commented 2 years ago

Finally, there is a standalone version of CLEARSWI: https://github.com/korbinian90/CompileMRI.jl/releases

drswgw commented 2 years ago

Hi Korbinian, I'm finding a bug in the linux version/matlab for SWI....according to me, it calls cmd_mag but doesn't define it...i tried adding cmd_mag = [ ' -m' mag_fn] but that changes the error from...no cmd_mag to not a string or vector (from memory...so not an exact bug report....). Am getting pretty seriously into unwrapping lately, so this is a very timely and very useful thing for me. I really like ROMEO....although am struggling to remove the pre-scaling....we are doing asynchronous time series...phase contrast...so we want to turn almost ALL of the presets off and just get very vanilla unwrapping...no shifting up and down, no prescaling, no post-scaling...that all SIGNAL for us....

drswgw commented 2 years ago

oh, am running entirely from matlab 2020 on Ubuntu 16

korbinian90 commented 2 years ago

Hi @drswgw Did the error occur in running the example_CLEARSWI_call.m or example_ROMEO_call.m Matlab script?

I don't use the matlab version myself and I might have changed something in the compiled version without adjusting the matlab caller. I will check and come back if I need additional information

Great to hear you are using ROMEO! For ROMEO, you can turn off the scaling of the input with --no-rescale (expects data in radians). By default it shouldn't perform more than unwrapping (adding/subtracting 2π from voxels). If you need more customization then available or have special questions, please ask ;) I think the best place would then be here: https://github.com/korbinian90/ROMEO/issues

korbinian90 commented 2 years ago

Hi @drswgw Thanks for reporting that bug! I think I fixed it, please test the new version v3.3.1: https://github.com/korbinian90/CompileMRI.jl/releases

drswgw commented 2 years ago

Selection_028 Hi Corbinian, Not sure if this will show up on your end as an image? anyway, tried the new version....

matlab line 65 error in clear SWI COMMAND must be a string scalar or character vector

the call to cmd_mag is probably fixed, but there is some other call? that is in the wrong format for matlab?

it's further downstream now...who knows, maybe it's on my end with the inputs? I don't think so, because ROMEO works OK...

Maybe it would help to know what I am doing....vanilla unwrapping, don't care about SWI, just want to pirate the Laplacian unwrapping. Our signal is all in the phase domain, the magnitude images are dead to us.

korbinian90 commented 2 years ago

Hi @drswgw ,

That is a weird problem. I used the matlab array concatenation syntax to join strings like [str1 str2]. On your machine that seems to have created an array of strings instead of concatenating them. I replaced these parts of code with strjoin({str1, str2}) instead, maybe that helps. (v3.3.2 https://github.com/korbinian90/CompileMRI.jl/releases)

From writing this reply, I have a second guess what might go wrong. Matlab has this new string type with double quotes "real_string", which seems to be very incompatible with the old type with single quotes 'char_array'. Maybe you used double quotes somewhere? I think this script works only with the single quote char arrays like 'tanh'

korbinian90 commented 2 years ago

For the second part, if you only need the laplacian unwrapping, you could try the julia version. It should be fairly simple:

  1. Install julia and add to PATH (https://julialang.org/downloads/platform/#linux_and_freebsd)
  2. Install Packages: run in the julia REPL: julia> import Pkg; Pkg.add("FFTW"); Pkg.add("MriResearchTools")
  3. Run a julia script in bash with $ julia unwrapping_script.jl

Example contents of unwrapping_script.jl

using MriResearchTools, FFTW

phasefile = "path-to-phase/phase.nii"
phase = readphase(phasefile; rescale=false) # rescale=true, if phase values should be scaled to a 2pi range
unwrapped = laplacianunwrap(phase)

savenii(unwrapped, "path-to-output/unwrapped.nii"; header=header(phase))

(or type these commands in the interactive julia REPL environment)

drswgw commented 2 years ago

Hi Korbinian, Julia should be fine. Will give that a whirl. Here is the previous errror in more detail. If you can define what the 'COMMAND' string should look like? Seems like it is just a matlab type error (the new versions of matlab have more/confusing types....not a huge fan of some of the changes....in general Matlab struggles to be...consistent). Basically passing a string seems like the hold up. Selection_029

drswgw commented 2 years ago

Hi Korbinian, OK, this looks like the 'fix'. The strjoin of all the subitems doesn't work....vsn 3.3.2, BUT...this looks like it does work...so just roll the code back a bit to 3.3.1...and add the strjoin LAST to strjoin the WHOLE string array right before passing it as the argument. i.e. your concatenate is working fine, but is generating a string array (probably becuase of the "SNR" or whatever other matlabness is going on). Selection_030

drswgw commented 2 years ago

SUCCESS....forgetabout previous comment.....MY BAD using "SNR", "laplacian" etc. ['a' 'b'] = 'ab' but ["a" "b"] doesn't work at all. So version 3.3.1, no further mods WORKS....version 3.3.2 probably doesn't work Selection_031 .

korbinian90 commented 2 years ago

I like your post from before, that seems to be a good solution! Then, the input can be char_arrays or strings, (hopefully) without weird errors. Wenn putting char_arrays and strings into an array, everything gets promoted to string. Then there is no type mismatch, when joining. (now you don't need it anymore, but theres a new v3.3.3 coming up, which allows strings and char_arrays)

stebo85 commented 2 years ago

the standalone version of clearswi is now inlcuded in Neurodesk :)

korbinian90 commented 2 years ago

I use the newest, julia 1.7.2 for ROMEO and CLEAR-SWI I think I set the minimum requirement to julia 1.5. The old julia 1.0.4 probably won't work, as I use some newer features. Compatibility in julia is very good, so using a newer julia version shouldn't be a problem.