Skip to content
This repository has been archived by the owner on May 18, 2021. It is now read-only.

Rt/ref shim opt deconstruct classes #153

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

rtopfer
Copy link
Contributor

@rtopfer rtopfer commented Jul 1, 2020

This PR will be part of a series dedicated to refactoring shim-related code in the current Coils subdir.

To break-up the immense refactor and hopefully facilitate code review, this initial PR simply migrates a couple ShimOpt methods into standalone functions within a new package.

To review/discuss:

  • subpackage folder name +b0shim/+compute

    • alternatively, it could be something like +b0shim/+math
    • proposed +compute so that a function call looks like basis = b0shim.compute.spherical_harmonics( ... ) rather than something like basis = b0shim.math.compute_spherical_harmonics( ... )
  • documentation format

Note: Code for computing coil induction fields via Biot-Savart can probably be added to this same subpackage (possibly in the same PR...)

(Also, p.s. some of the code is inherited so it doesn't completely follow the style convention)

rtopfer added 2 commits June 30, 2020 23:15
…thod into new package +b0shim/+compute/spherical_harmonics.m
@rtopfer rtopfer requested review from jcohenadad and po09i July 1, 2020 21:06
%
% INPUTS
%
% orders
Copy link
Member

Choose a reason for hiding this comment

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

i would like very much to see the type indicated for each variable. This is super useful for people not familiar with the code. I've suggested it in this PR (https://github.com/shimming-toolbox/shimming-toolbox/pull/145/files#diff-f7c3aae9cf7ffff5e623bbb43d946a50), which we should merge at some point.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

since matlab isn't strongly typed, we need a convention to indicate generic variables (e.g. numeric to encompass double, single, int, etc.?)

it's also a bit unfortunate since, for instance, orders in this case should be integers — but doesn't need to be typed as such, so suggesting the specific type is a bit misleading...

Copy link
Member

Choose a reason for hiding this comment

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

% distance from iso/origin to adopted reference point [units: mm]
r = [1 1 1 1 sqrt(2) sqrt(2) 1 sqrt(2)] ;

% invert polarity of certain terms:
Copy link
Member

Choose a reason for hiding this comment

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

any refs here would be welcome

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm... none available, just worked this out myself^

Copy link
Member

Choose a reason for hiding this comment

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

in that case i would add something like: "(found empirically)". just for transparency.

% invert polarity of certain terms:
sh(:,:,:,[2,3,5,8]) = -sh(:,:,:,[2,3,5,8] ) ;

orders = [1 1 1 2 2 2 2 2] ;
Copy link
Member

Choose a reason for hiding this comment

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

maybe mention in the header that currently the function only works for up to 2nd SH order, and open a feature issue to cover 2+ orders?

%
% 1. For now, `orders` is, in fact, ignored: fixed as [1:2]—which is suitable
% for the Prisma (presumably other Siemens systems as well)—however, the
% 3rd-order shims of the Terra should ultimately be accommodated too. (Requires
Copy link
Member

Choose a reason for hiding this comment

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

ah! i'm just seeing this-- scrap this comment then.
i would still open an issue-- much more convenient for project management (than having someone open each .m file and look for "todo" fields)

% vector of non-negative integers (`[0:1:n]` yields harmonics up to n-th
% order)
%
% X, Y, Z
Copy link
Member

@jcohenadad jcohenadad Jul 1, 2020

Choose a reason for hiding this comment

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

these are separate input params (not a single ndarray), so i would do:

%    X (numeric)
%      X-coordinate in the patient-coordinate system (i.e. DICOM reference, units of mm)
%
%    Y (numeric)
%      Y-coordinate in the patient-coordinate system (i.e. DICOM reference, units of mm)
%
%    Z (numeric)
%      Z-coordinate in the patient-coordinate system (i.e. DICOM reference, units of mm)

Copy link
Member

Choose a reason for hiding this comment

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

and to suggest that both 2d or 3d work, i would update the usage above:

%    basis = siemens_basis( orders, X, Y )
%    basis = siemens_basis( orders, X, Y, Z )

Copy link
Contributor Author

Choose a reason for hiding this comment

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

and to suggest that both 2d or 3d work, i would update the usage above:

%    basis = siemens_basis( orders, X, Y )
%    basis = siemens_basis( orders, X, Y, Z )

"2d" refers to computing the basis on a single slice—still need the Z coordinates in either case

Copy link
Member

Choose a reason for hiding this comment

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

and to suggest that both 2d or 3d work, i would update the usage above:

%    basis = siemens_basis( orders, X, Y )
%    basis = siemens_basis( orders, X, Y, Z )

"2d" refers to computing the basis on a single slice—still need the Z coordinates in either case

ha! another good example that expliciting what type/size is expected is important for people not familiar with the code (i.e., me 😅).

@rtopfer
Copy link
Contributor Author

rtopfer commented Jul 7, 2020

@jcohenadad on this note, can we merge?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants