首页 > > 详细

讲解 MPHY0020 MATLAB coursework 2025讲解 留学生Matlab程序

MPHY0020 MATLAB coursework 2025

Introduction and guidance

The tasks for the coursework are described in detail below.They are related to the signal processing and data visualisation required for brain MRI. All the required mathematical formulas and algorithms are provided,but you willneed to implement these using MATLAB, thinking carefully about the steps needed to complete each task.

When you submit your solution,you should:

·     Submit allthe .m files you created for this coursework. Include all functions and scripts.

·      Name the functions and scripts in such a way that it is clear what each function or  script.  does, e.g. MRI_process and Task1  for a function  that  processes  the  MRI and for the script for Task 1,respectively.

·     In addition, submit a text file that outlines which .m file corresponds to which task.

·     Combine all scripts and functions into a single .zip file and upload this single file to Moodle.

· Include only your student number in the file name-do not include your name! Please note:

·     Do not submit graphics,videos and figures;instead ensure your codes generate the figures at run-time in exactly the way you wish them to look. Also do not submit the data sets.

This MATLAB coursework accounts for 34% of the total course mark. Marks for this coursework willbe awarded using the following criteria:

·     Up to 60%will be based on whether your code correctly implements the methods and mathematics described for each task,and in addition produces the correct results and clear visualisations.

·     Upto 25%willbe based on how easy it is to understand and use your code. This includes the use of both internal and external comments,informative variable and function names,and clarity and structure of the code.

·     Upto  15%will be based on adhering to other good programming practices that you have learned about in the lectures,such as memory management,error checking, and vectorisation.

Marks for implementation correctness will be awarded for each task individually (the marks available are indicated next to each task number),whereas the marks for clarity and good practice will be awarded based on your entire solution.

Please be aware that submitted coursework will be compared for similarity with other s ubmitted coursework and code available elsewhere (e.g. on the internet). This does not prevent you from discussing the coursework with others or using the various sources of help  mentioned in the lectures,it just means you have to devise and write your own code.Generative (or other)Al platforms must not be used to generate any of the codes you submit.

Magnetic Resonance Imaging (MRI) is one of the most widely used medical imaging modalities, capable of generating high-resolution images of soft tissues without ionising radiation.Unlike  ultrasound or X-ray imaging, which record signals directly in the spatial domain,MRI data is collected in the frequency domain, known as k-space.The final image is reconstructed from this k-space data by means of inverse  Fourier transformation and subsequent processing steps.

In this coursework,you willwork with both 2D and 3D MRI datasets in MATLAB,starting from raw k-space data and progressing toward  full 3D image  reconstruction, filtering, rotation correction,and  segmentation. The tasks are designed to gradually introduce you  to  the principles of MRI signal  processing, from simple Fourier reconstruction  to segmentation of anatomical structures and tumours.

Unless explicitly stated otherwise, allparameter values set in one task should be kept constant in subsequent tasks.Throughout,you are expected to ensure visualisations are informative in layout and appearance suitable for MRI data visualisation.

Task 1 [10]

MRI scanners acquire raw data in the spatial frequency domain(k-space). Each point in k-space corresponds to a spatial frequency   component of the final image, and only after transformation into the image domain can  anatomical structures be visualised. However, k- space itself is often inspected to understand the spatial distribution of signal energy and noise characteristics.

For this task, please download the dataset  "kspace_single_slice.mat"from  Moodle,which contains the raw k-space for a single MRI slice. You should write a MATLAB script that loads this dataset into the workspace and displays the magnitude of the k-space values. To improve interpretability,you should apply a logarithmic transform by computing

L=|log10 E|,

where L(in dB)is the log-compressed result of the k-space data E.The image should be displayed with a suitable colormap with 20 dB dynamic range. A colour bar should be displayed next to your image.

Importantly, the axes of k-space should not simply be shown as pixel indices, but instead converted into spatial frequency coordinates in  mm⁻¹. To do this, you must use the pixel spacing values  provided. For this dataset,△x=△y=0.43mm. The frequency axes are obtained  by computing:

Where FOVxand FOVy are the field of view in millimetre,Nx and Ny are the image matrix dimensions in pixels,Δx and Δy are the pixel spacings in millimetres,and kxand ky are the spatial frequency axes in mm⁻¹.

Task 2 [15]

Whilst k-space is informative,it cannot be directly interpreted by clinicians.A more clinically meaningful image can be obtained by reconstructing the data into the spatial domain through the inverse Fourier transform.The second task will therefore focus on image reconstruction from the k-space dataset considered in Task 1.

For this task,write a script that reconstructs the  MRI image.The script should process the complex k-space array from Task 1 into a reconstructed image.Your script should implement a two-dimensional inverse Fourier transform on the k-space data,scale the image so that the maximum pixel value of the image equals 1,and display the image.

Task 3 [20]

MRI  k-space  filtering  allows  us  to  selectively  preserve  or  suppress  spatial  frequency  components   in  the   reconstruction.The   central   region   of   k-space   corresponds  to   low  frequencies,and contains mostly information on image contrast and gross anatomical features, while the edges of k-space contain high frequencies responsible for fine structural details.By  applying  low-pass filtering,high-frequency  detail  is  suppressed,resulting  in  a  smoother  but  blurrier  image.Conversely,high-pass  filtering  suppresses  the  central,low-frequency  content,  resulting in edge-enhancement but with reduced overall contrast.

In this task,you will write a MATLAB function that applies a circular spectral filter to k-space data and reconstructs the corresponding image.The function should be able to read a raw k- space  dataset,allow  the  user  to  select  the  filter  type  (low-pass,high-pass,or  no  filter),and specify the cut-off frequency.The cut-off frequency should be normalised between 0 and 1, where O corresponds to the centre of k-space and 1 corresponds to the outermost frequency

Inside the function,you should generate a binary mask in the shape of a circle,centred at the origin of k-space.For the low-pass case,the mask should retain all k-space values inside the circle  (blanking  out  values  outside).For  the  high-pass  case,the  opposite  should  be  done, retaining  values  outside  the  circle  and  blanking  out  the  centre.The  function  should  then inverse Fourier transform the filtered k-space data into the image domain,and the magnitude of the resulting image should be normalised such that its maximum pixel value is equal to 1. The function should return this reconstructed image and it's corresponding filtered k-space data.

In a separate script,you should load the single-slice k-space dataset,call your function three times to generate:

1.The  unfiltered  reconstruction  (for  comparison).

2.The  low-pass filtered  reconstruction,with  normalised  cut-off  spatial frequency  of 0.1.

3.The  high-pass  filtered  reconstruction,with  normalised  cut-off  spatial  frequency  of 0.01.

Finally,display the reconstructed MRI image with its corresponding filtered k-space image in a single  6-panel  figure  window  using  subplots.Sample  outputs  are  shown  below,but  other layouts are acceptable.

Figure 1.

Up until now you have considered only a single two-dimensional slice.However,MRI data is inherently volumetric,and three-dimensional acquisitions allow structures such as the brain to    be     visualised    in      multiple      planes.For      this      task,    download     the     dataset "kspace3D_tumour.mat"from Moodle,which contains a full 3D k-space acquisition of a head with an embedded tumour.

Write a script that loads this dataset,and applies a 3D fast inverse Fourier transform to form the 3D volume.From the  reconstructed 3D volume,display three orthogonal slices centred within the image volume in one axis.Ensure your visualisation has the correct appearance and is not spatially distorted.

Task 5 [15]

In some cases,MRI data may not be perfectly aligned with the imaging axes due to patient positioning or scanner calibration.As a result,the reconstructed volume may appear rotated for each axial slice,as in the 3D MRI data used in task 4.As such,subsequent analysis (such as segmentation)may  be  inaccurate.

For this task,you should correct the orientation of the reconstructed brain volume from Task 4.You  should  determine  the  appropriate  transformation  (e.g.,imrotate  or  interp3)to  undo the rotation using 15°off-set for each axial slice.Finally,display the corrected data again in a visualisation matching that for Task 4.

Task 6[20]

Segmentation of tumours in  MRI volumes  is an essential step in medical image analysis, supporting both clinical assessment and quantitative studies.One intuitive approach is to use the pixel intensity distribution to identify the tumour.Typically,tumour tissue exhibits intensity values that are distinct from surrounding brain tissue.Histogram analysis can help identify an appropriate threshold for segmentation.

For this task,you will first work with a single slice,and then extend the segmentation to the full  3D  volume.Write  a  single  script.  to  perform.  both  parts  of  this  task,and  a  function  to compute the Dice coefficient explained below.

Step 1:Single-slice segmentation

1.Select a representative slice from the de-rotated 3D reconstructed volume from task 5;for this task,use slice number 15(axial plane,figure 2).


Figure 2.

2.Plot  the   histogram  of  pixel  intensities  in  this   slice.Examine  the   histogram  to   identify an  intensity  range  corresponding  to  the  tumour,and  annotate the selected  pixel  value range   onto   the   histogram,for   instance   using   the   ‘xline'command.Other   annotation styles  are  acceptable.

3.Apply  thresholding  to  generate  a  binary  mask  for  the  tumour  in  this  slice:pixels  within the  chosen  intensity  range  should  be  assigned  a  value  of  1(tumour),and  all  others should   be  0(background).

4.To  clearly  visualise  the  segmentation  result,overlay  the  binary  tumour  mask  on  top  of the  original  grayscale  MRI  slice  using  a  different  colour  (eg.Figure  3).This  allows  the tumour   region   to    be    highlighted    while    preserving    visibility   of   the    underlying anatomical  structures.Sample  outputs  are  shown  below,but  other  visualisations  are acceptable.

5.Display  the  histogram,tumour  binary  mask,and  overlayed  image  in  multiple  planes

within  a  single figure window  using  subplots.

Figure  3.

Step 2:3D volume segmentation

1.Extend   your   thresholding    approach   to    the   full    de-rotated   3D    reconstructed   MRI volume  from  task  5.Examine  the  histogram  of  the  voxel  intensity  in  this  3D  volume

and  annotate  the  selected  pixel  value  range  onto  the  histogram.Apply  the  intensity threshold across the entire 3D volume to generate a 3D binary mask representing the tumour.

2.Download    the    file“ground_truth.mat”,which    contains    the    ground-truth     3D    tumour mask,from  Moodle.Write  a  function  to  compare  your  3D  segmented  tumour  mask with  the  ground-truth   mask  and   compute  the   Dice  coefficient,and   have  your  script display  the  Dice  result  in  the  command  window  in  an  elegant  fashion.This  Dice coefficient  measures  the  similarity   between  two  3D   binary  volumes.It   is  defined  as twice the  number of overlapping voxels divided  by the total  number of voxels  in  both volumes  combined.A  Dice  coefficient  of  1  indicates  perfect  overlap,while  0  indicates no   overlap.Mathematically,for   two   binary   masks   A   and   B,the   Dice   coefficient   is calculated  as:

where    |A|and    |B|are    the    number    of   voxels    in    each    mask,and    |A∩B|is    the number of voxels where  both  masks  overlap.

3.Render the tumour as a 3D volume using MATLAB's volume visualisation tools such as 'volshow’,'isosurface',or'patch'.Other   appropriate   approaches   are   acceptable.The 3D rendering should clearly display the spatial extent of the tumour within the brain, allowing  intuitive  appreciation  of  its  shape  and  location.Ensure  you   manipulate transparency,colour,and lighting to achieve an informative and pleasing visualisation.

Task 7 [10]-Level 7 students only!

In addition to tumour segmentation,MRI can be used to study the internal structure of the brain.Different anatomical  regions,such  as  grey  matter,white  matter,cerebrospinal  fluid,and bone,often  exhibit  distinct  intensity  characteristics  in  T1-or  T2-weighted  images.Accurate segmentation of these regions is important forquantitative neuroimaging,volumetric analysis, and functional studies.

For this task,you will segment multiple head MRI regions on axial slice number 15 from the de-rotated 3D reconstructed volume from Task 5.Depending on the intensity values,multiple thresholds may be required to separate the following four anatomical features;skull,tumour, brain,and subarachnoid space (see Fig.4 which highlights these anatomical features).In this task,write a script to perform binary segmentation,as in Task 6,to generate initial masks for each structure.Once the masks are created,apply morphological image processing operations to refine the segmentation and produce clear boundaries for each region.Accuracy is not the primary concern;the focus is on obtaining visually distinct structures.

Finally,assign  distinct  labels  or  colours  to  each  segmented  region(bone,tumour,brain,and subarachnoid space),so that all structures can be visualised simultaneously.You may either overlay the masks on the original MRI slice or draw the boundaries using contours.Ensure that your  visualisation  clearly  indicates  which  segmentation  corresponds  to  each  anatomical structure.Sample outputs are provided below,but othervisualisations are acceptable-as long as your result clearly distinguishes and displays each region.

Figure 4. Red: bone; green: subarachnoid space; blue: brain; pink: tumour.




联系我们
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp
热点标签

联系我们 - QQ: 99515681 微信:codinghelp
程序辅导网!