diff --git a/README.md b/README.md index 8defd77..7135958 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/documentation/images/.gitignore b/documentation/images/.gitignore new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/documentation/images/.gitignore @@ -0,0 +1 @@ + diff --git a/documentation/images/gradientDesignTool.png b/documentation/images/gradientDesignTool.png new file mode 100644 index 0000000..7f28fe9 Binary files /dev/null and b/documentation/images/gradientDesignTool.png differ diff --git a/gradientCalculationV2_1.py b/gradientCalculationV2_1.py index e8bfd09..4ac4afb 100644 --- a/gradientCalculationV2_1.py +++ b/gradientCalculationV2_1.py @@ -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) @@ -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) @@ -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 @@ -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,:]) @@ -296,54 +296,3 @@ def exportWires(contours, coilRad, direction, conjoined): joinedContour[key] = np.delete(joinedContour[key],np.nonzero(zeroElements), axis = 0) return joinedContour - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/gradientDesignTool.py b/gradientDesignTool.py index 9564ac5..ac6f29d 100644 --- a/gradientDesignTool.py +++ b/gradientDesignTool.py @@ -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] @@ -306,4 +306,4 @@ def exportWireCSV(self): app = GDT_GUI() app.mainloop() -closePlots('all') \ No newline at end of file +closePlots('all') diff --git a/requirements.txt b/requirements.txt index b6cba1f..f2b2a0c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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