Commit 04fe9afd authored by Saad Jbabdi's avatar Saad Jbabdi
Browse files

added copyright and bits od docstring

parent 2c2f2e1a
......@@ -3,6 +3,7 @@
# constants.py - Definition of all the constants
#
# Author: Saad Jbabdi <saad@fmrib.ox.ac.uk>
# William Clarke <william.clarke@ndcn.ox.ac.uk>
#
# Copyright (C) 2019 University of Oxford
# SHBASECOPYRIGHT
......
""" Module containing alignment functions (align and aligndiff)"""
#!/usr/bin/env python
# align.py - Module containing alignment functions (align and aligndiff)
#
# Author: Saad Jbabdi <saad@fmrib.ox.ac.uk>
# William Clarke <william.clarke@ndcn.ox.ac.uk>
#
# Copyright (C) 2019 University of Oxford
# SHBASECOPYRIGHT
from fsl_mrs.utils.preproc.general import get_target_FID,add,subtract
from fsl_mrs.core import MRS
from fsl_mrs.utils.misc import extract_spectrum,shift_FID
......@@ -192,6 +201,9 @@ def phase_freq_align_diff(FIDlist0,FIDlist1,bandwidth,centralFrequency,diffType
# Reporting functions
def phase_freq_align_report(inFIDs,outFIDs,hdr,phi,eps,ppmlim=None,shift=True,html=None):
"""
Generate phase alignment report
"""
from fsl_mrs.utils.preproc.combine import combine_FIDs
import plotly.graph_objects as go
from fsl_mrs.utils.preproc.reporting import plotStyles,plotAxesStyle
......@@ -527,4 +539,4 @@ def phase_freq_align_diff_report(inFIDs0,inFIDs1,outFIDs0,outFIDs1,hdr,eps,phi,p
# styleSpectrumAxes(ax=plt.gca())
# plt.legend()
# plt.rcParams.update({'font.size': 12})
# plt.show()
\ No newline at end of file
# plt.show()
'''Module containing functions for combining FIDs, includes coil combination.'''
#!/usr/bin/env python
# combine.py - Module containing functions for combining FIDs, includes coil combination
#
# Author: Saad Jbabdi <saad@fmrib.ox.ac.uk>
# William Clarke <william.clarke@ndcn.ox.ac.uk>
#
# Copyright (C) 2019 University of Oxford
# SHBASECOPYRIGHT
import numpy as np
......@@ -287,4 +297,4 @@ def combine_FIDs_report(inFIDs,outFID,hdr,ncha=2,ppmlim = (0.0,6.0),method='not
# for fid in toPlotOut:
# ax.plot(fid.getAxes(ppmlim=ppmlim),np.real(fid.getSpectrum(ppmlim=ppmlim)),'k-')
# styleSpectrumAxes(ax)
# plt.show()
\ No newline at end of file
# plt.show()
#!/usr/bin/env python
# eddycorrect.py - Eddy current correction routines
#
# Author: Saad Jbabdi <saad@fmrib.ox.ac.uk>
# William Clarke <william.clarke@ndcn.ox.ac.uk>
#
# Copyright (C) 2019 University of Oxford
# SHBASECOPYRIGHT
import numpy as np
def eddy_correct(FIDmet,FIDPhsRef):
"""
......@@ -17,6 +27,9 @@ def eddy_correct(FIDmet,FIDPhsRef):
return np.abs(FIDmet) * np.exp(1j*(np.angle(FIDmet)-phsRef))
def eddy_correct_report(inFID,outFID,phsRef,hdr,ppmlim = (0.2,4.2),html=None):
"""
Generate Eddy correction report
"""
# from matplotlib import pyplot as plt
from fsl_mrs.core import MRS
import plotly.graph_objects as go
......@@ -120,4 +133,4 @@ def eddy_correct_report(inFID,outFID,phsRef,hdr,ppmlim = (0.2,4.2),html=None):
# styleSpectrumAxes(ax=plt.gca())
# plt.legend()
# plt.rcParams.update({'font.size': 12})
# plt.show()
\ No newline at end of file
# plt.show()
#!/usr/bin/env python
# filtering.py - Routines for FID filtering
#
# Author: Saad Jbabdi <saad@fmrib.ox.ac.uk>
# William Clarke <william.clarke@ndcn.ox.ac.uk>
#
# Copyright (C) 2019 University of Oxford
# SHBASECOPYRIGHT
import numpy as np
def apodize(FID,dwelltime,broadening,filter='exp'):
......@@ -24,6 +34,9 @@ def apodize(FID,dwelltime,broadening,filter='exp'):
def apodize_report(inFID,outFID,hdr,plotlim = (0.2,6),html=None):
"""
Generate report
"""
# from matplotlib import pyplot as plt
from fsl_mrs.core import MRS
import plotly.graph_objects as go
......@@ -85,4 +98,4 @@ def apodize_report(inFID,outFID,hdr,plotlim = (0.2,6),html=None):
singleReport(htmlfile,opName,headerinfo,figurelist)
return fig
else:
return fig
\ No newline at end of file
return fig
"""General preprocessing functions"""
#!/usr/bin/env python
# general.py - General preprocessing functions
#
# Author: Saad Jbabdi <saad@fmrib.ox.ac.uk>
# William Clarke <william.clarke@ndcn.ox.ac.uk>
#
# Copyright (C) 2019 University of Oxford
# SHBASECOPYRIGHT
import numpy as np
from dataclasses import dataclass
......@@ -38,6 +48,9 @@ def add(FID1,FID2):
return (FID1+FID2)/2.0
def add_subtract_report(inFID,inFID2,outFID,hdr,ppmlim=(0.2,4.2),function='Not specified',html=None):
"""
Generate report
"""
# from matplotlib import pyplot as plt
from fsl_mrs.core import MRS
import plotly.graph_objects as go
......@@ -101,4 +114,4 @@ def add_subtract_report(inFID,inFID2,outFID,hdr,ppmlim=(0.2,4.2),function='Not s
singleReport(htmlfile,opName,headerinfo,figurelist)
return fig
else:
return fig
\ No newline at end of file
return fig
#!/usr/bin/env python
# phasing.py - Phase correction routines
#
# Author: Saad Jbabdi <saad@fmrib.ox.ac.uk>
# William Clarke <william.clarke@ndcn.ox.ac.uk>
#
# Copyright (C) 2019 University of Oxford
# SHBASECOPYRIGHT
import numpy as np
from fsl_mrs.core import MRS
from fsl_mrs.utils.misc import extract_spectrum
from fsl_mrs.utils.preproc.shifting import pad
from fsl_mrs.utils.preproc.remove import hlsvd
def applyPhase(FID,phaseAngle):
"""
Multiply FID by constant phase
"""
return FID * np.exp(1j*phaseAngle)
def phaseCorrect(FID,bw,cf,ppmlim=(2.8,3.2),shift=True):
......@@ -40,6 +53,9 @@ def phaseCorrect(FID,bw,cf,ppmlim=(2.8,3.2),shift=True):
return applyPhase(FID,phaseAngle),phaseAngle,int(np.round(maxIndex/4))
def phaseCorrect_report(inFID,outFID,hdr,position,ppmlim=(2.8,3.2),html=None):
"""
Generate report
"""
# from matplotlib import pyplot as plt
from fsl_mrs.core import MRS
import plotly.graph_objects as go
......@@ -139,4 +155,4 @@ def phaseCorrect_report(inFID,outFID,hdr,position,ppmlim=(2.8,3.2),html=None):
# styleSpectrumAxes(ax=plt.gca())
# plt.legend()
# plt.rcParams.update({'font.size': 12})
# plt.show()
\ No newline at end of file
# plt.show()
#!/usr/bin/env python
# remove.py - HLSVD-based correction
#
# Author: Saad Jbabdi <saad@fmrib.ox.ac.uk>
# William Clarke <william.clarke@ndcn.ox.ac.uk>
#
# Copyright (C) 2019 University of Oxford
# SHBASECOPYRIGHT
import numpy as np
import hlsvdpro
from fsl_mrs.utils.misc import checkCFUnits
......@@ -48,6 +58,9 @@ def hlsvd(FID,dwelltime,centralFrequency,limits,limitUnits = 'ppm',numSingularVa
return FID - sumFID
def hlsvd_report(inFID,outFID,hdr,limits,limitUnits = 'ppm',plotlim = (0.2,6),html=None):
"""
Generate report
"""
# from matplotlib import pyplot as plt
from fsl_mrs.core import MRS
import plotly.graph_objects as go
......@@ -151,4 +164,4 @@ def hlsvd_report(inFID,outFID,hdr,limits,limitUnits = 'ppm',plotlim = (0.2,6),ht
# styleSpectrumAxes(ax=plt.gca())
# plt.legend()
# plt.rcParams.update({'font.size': 12})
# plt.show()
\ No newline at end of file
# plt.show()
#!/usr/bin/env python
# reporting.py - Routines for generating proc reports
#
# Author: William Clarke <william.clarke@ndcn.ox.ac.uk>
#
# Copyright (C) 2019 University of Oxford
# SHBASECOPYRIGHT
from jinja2 import FileSystemLoader, Environment
import os.path as op
from dataclasses import dataclass
......
#!/usr/bin/env python
# shifting.py - Shifting routines
#
# Author: Saad Jbabdi <saad@fmrib.ox.ac.uk>
# William Clarke <william.clarke@ndcn.ox.ac.uk>
#
# Copyright (C) 2019 University of Oxford
# SHBASECOPYRIGHT
import numpy as np
from fsl_mrs.core import MRS
from fsl_mrs.utils.misc import extract_spectrum
......@@ -106,7 +116,10 @@ def pad(FID,k,first_or_last='last'):
else:
raise(Exception("Last parameter must either be 'first' or 'last'"))
def shift_report(inFID,outFID,inHdr,outHdr,ppmlim = (0.2,4.2),html=None,function='shift'):
def shift_report(inFID,outFID,inHdr,outHdr,ppmlim = (0.2,4.2),html=None,function='shift'):
"""
Generate report
"""
import plotly.graph_objects as go
from plotly.subplots import make_subplots
from fsl_mrs.utils.preproc.reporting import plotStyles,plotAxesStyle
......@@ -241,4 +254,4 @@ def reportStrings(funcName):
# ax2.autoscale(enable=True, axis='x', tight=False)
# plt.rcParams.update({'font.size': 12})
# plt.show()
\ No newline at end of file
# plt.show()
#!/usr/bin/env python
# unlike.py - Outlier detection routines
#
# Author: William Clarke <william.clarke@ndcn.ox.ac.uk>
#
# Copyright (C) 2019 University of Oxford
# SHBASECOPYRIGHT
from fsl_mrs.core import MRS
import numpy as np
from fsl_mrs.utils.preproc.general import get_target_FID
......@@ -202,4 +211,4 @@ def identifyUnlikeFIDs_report(goodFIDs,badFIDs,hdr,keepIndicies,rmIndicies,metri
# plt.plot(tgtmrs.getAxes(ppmlim=ppmlim),np.real(tgtmrs.getSpectrum(ppmlim=ppmlim)),'k',label='Target')
# styleSpectrumAxes(plt.gca())
# plt.legend()
# plt.show()
\ No newline at end of file
# plt.show()
#!/usr/bin/env python
# qc.py - Calculate various QC measures
#
# Author: William Clarke <william.clarke@ndcn.ox.ac.uk>
#
# Copyright (C) 2019 University of Oxford
# SHBASECOPYRIGHT
from fsl_mrs.utils import models
from fsl_mrs.utils.misc import FIDToSpec,SpecToFID
from fsl_mrs.core import MRS
......@@ -9,6 +18,8 @@ import pandas as pd
SNR = namedtuple('SNR',['spectrum','peaks','residual'])
class NoiseNotFoundError(ValueError):
pass
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment