-
Notifications
You must be signed in to change notification settings - Fork 164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MATLAB Wrapper and tools that output the result with bart_printf #228
Comments
I can try to play around with the MATLAB wrapper and got some ideas on how to make it work. Can you post a minimal working example, best with phantom data, on how to use the estdelay command? something like: traj = bart(...)
data = bart(...)
out = bart('estdelay',traj,data) Then I could take this to play around with it :-) |
MWE as requested
Ideally, I would also strip trailing line breaks from |
Looking into it I also can't see any nice solution for this, there are many limitations that really screw this up.
Instead of overly complicating the MATLAB wrapper I'm just wondering if it would make sense to fix and improve the BART tools that are using bart_printf() at the moment. Would it make sense to give those tools an optional output parameter? When set the actual BART tools would just write the calculated/estimated parameters to a 1-dimensional cfl file (and even if it just contains a single value). The MATLAB wrapper would just read that file and return the values from it. And even when using BART from the command line one could use this mechanism for storing the estimated values in a file. One could alternatively allow for using just .txt files as output extension. |
A quick note on (1): In the python wrapper, which I wrote to be very similar to the Matlab version, I had to make a similar compromise where the first argument to the "bart" function was the number of expected outputs. Maybe it is worth to bring that argument to the Matlab wrapper as well? |
It would, of course, be an option, but I think one would then also have to add another option to differentiate between file output parameters and variable/value output parameters like the thread started asked for (dumped to console via bart_printf()). And then things start to become more and more complicated for the user to use. One option of course would be to have it as optional named varargin parameter like this: out = bart('estdelay',traj,data,'DirectOutputs, 1); but this would still not solve the problem with the non-standardized output of the functions that are using bart_printf() and the required string parsing madness to transform the grabbed stdout to a value/array. But it would at least not interfere or break with the current functionality and usage. |
I do not think parsing is as bad as you think. There are only a couple of commands where it makes sense to parse the output into an array. For these, you need to remove a text prefix followed by a colon, and then either parse a series of numbers, complex numbers, or the the 3-vector %f:%f:%f |
Was just hoping for a more generic solution :-) Then I guess the remaining question is how to implement it into the wrappers' interface, I would like to not keep the current very simple functionality. So maybe extending by an optional named varargin like |
We were thinking about having an option to output a machine-readable specification for each command-line tool that describes input and output. This could then be used by wrappers. But I am not sure how to deal with output. |
I ran into an issue with the MATLAB wrapper when using tools that output the result with bart_printf, in particular estdelay. Ideally, I would like to get the output as a variable in MATLAB. Using
out = bart('estdelay',traj,data)
results in an error because there is no output from estdelay. I'm aware that I could capture the command window output by doing something likeout = evalc("bart('estdelay',traj,data)");
or but it's not very tidy.I made a very hacky attempt to have bart.m attempt to drop the
out_str
and try again if it detects a specific error message. Whereas it doesn't seem to break any code for me, it's might result in unforeseen consequences down the line. Another approach would be to have bart.m recognize these tools based on thecmd
-string and handle them accordingly, i.e. calling bart without anout_str
, but this doesn't seem like a very clean solution either.The text was updated successfully, but these errors were encountered: