Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
# GradientDesignTool


A design tool for creating gradient coils for Halbach array based MRI systems based on the Target Field Method initially proposed by Turner.

Run gradientDesignTool.py to load the GUI.

```bash
$ git clone --depth 1 https://github.com/LUMC-LowFieldMRI/GradientDesignTool GradientDesignTool
$ cd GradientDesignTool
$ python -m venv venv
$ source venv/bin/activate
$ pip install -r requirements.txt
$ python ./gradientDesignTool.py
```

Note; The tool is fully functional but still in an early beta version and can be unstable. A known issue is that the outer-most wires can be open, this will cause problems in simulating the gradient fields and will cause the wire export to be stuck in a permanent loop. Tweaking the parameters can eliminate the open wires (setting the number of higher order modes to 0 seems to work well).

![gradientDesignTool screenshot](./documentation/images/gradientDesignTool.png)
1 change: 1 addition & 0 deletions documentation/images/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Binary file added documentation/images/gradientDesignTool.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
59 changes: 4 additions & 55 deletions gradientCalculationV2_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def halbachXgradient(linearLength = 140, coilRad = 135, coilLength = 350,numWire
N = numHighOrders
h = apoTerm

Nsamp = np.int(2*Zmax/res)
Nsamp = int(2*Zmax/res)
z = np.linspace(-Zmax,Zmax,Nsamp)
phi = np.linspace(-1.5*np.pi,0.5*np.pi,Nsamp)

Expand Down Expand Up @@ -91,7 +91,7 @@ def halbachYgradient(linearLength = 140, coilRad = 135, coilLength = 350, numWir
print("Number of higher order modes set to 0, not needed for Y and Z")
h = apoTerm

Nsamp = np.int(2*Zmax/resolution)
Nsamp = int(2*Zmax/resolution)
z = np.linspace(-Zmax,Zmax,Nsamp)
phi = np.linspace(-np.pi,np.pi,Nsamp)

Expand Down Expand Up @@ -134,7 +134,7 @@ def halbachZgradient(linearLength = 140, coilRad = 135, coilLength = 350, numWir
#print("Number of higher order modes set to 0, not needed for Y and Z")
h = apoTerm

Nsamp = np.int(2*Zmax/resolution)
Nsamp = int(2*Zmax/resolution)
z = np.linspace(-Zmax,Zmax,Nsamp)
phi = np.linspace(-np.pi,np.pi,Nsamp)+np.pi/4

Expand Down Expand Up @@ -193,7 +193,7 @@ def calculateBfield(contours, DSV, resolution, coilRad, direction):
wireCounter = 1
for wireLevel in wireLevels:
for wire in wireLevel:
print("Simulating wire %.0f of %0.f"%(wireCounter, np.size(wireLevels)))
#print("Simulating wire %.0f of %0.f"%(wireCounter, wireLevels))
wire = np.array(wire, dtype = np.float32)
wirePath3D = np.stack((np.cos(wire[:,0])*np.float32(coilRad),np.sin(wire[:,0])*np.float32(coilRad),wire[:,1]),axis=1)
idS = 1e-7*gradCurrent*(wirePath3D[1:,:] - wirePath3D[:-1,:])
Expand Down Expand Up @@ -296,54 +296,3 @@ def exportWires(contours, coilRad, direction, conjoined):
joinedContour[key] = np.delete(joinedContour[key],np.nonzero(zeroElements), axis = 0)

return joinedContour



















































4 changes: 2 additions & 2 deletions gradientDesignTool.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def calculateGradientWires(self):
self.contourfig.gca().set_xlabel('Z (mm)')
self.contourfig.gca().set_ylabel('Y (mm)')
self.contourfig.gca().set_zlabel('X (mm)')
np.warnings.filterwarnings('ignore', category=np.VisibleDeprecationWarning)
#np.warnings.filterwarnings('ignore', category=np.VisibleDeprecationWarning)
self.length = 0
for idx, wireLevel in enumerate(wireLevels):
currentLevel = self.contourData.levels[idx]
Expand Down Expand Up @@ -306,4 +306,4 @@ def exportWireCSV(self):

app = GDT_GUI()
app.mainloop()
closePlots('all')
closePlots('all')
19 changes: 11 additions & 8 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
cycler==0.10.0
kiwisolver==1.2.0
matplotlib==3.2.1
numpy==1.18.3
pyparsing==2.4.7
python-dateutil==2.8.1
scipy==1.4.1
six==1.14.0
cycler==0.12.1
Cython==3.0.10
kiwisolver==1.4.5
matplotlib==3.2.0rc1
numexpr==2.10.0
numpy==1.26.4
pybind11==2.12.0
pyparsing==3.1.2
python-dateutil==2.9.0.post0
scipy==1.13.1
six==1.16.0