Commit c4d41793 authored by William Clarke's avatar William Clarke
Browse files

Flake formatting on rest of preproc.

parent 61089ace
# Make core preprocessing functions availible at module level
from fsl_mrs.utils.preproc.combine import combine_FIDs
from fsl_mrs.utils.preproc.align import phase_freq_align,phase_freq_align_diff
from fsl_mrs.utils.preproc.phasing import phaseCorrect,applyPhase
from fsl_mrs.utils.preproc.align import phase_freq_align, phase_freq_align_diff
from fsl_mrs.utils.preproc.phasing import phaseCorrect, applyPhase
from fsl_mrs.utils.preproc.eddycorrect import eddy_correct
from fsl_mrs.utils.preproc.shifting import truncate,pad,timeshift,freqshift,shiftToRef
from fsl_mrs.utils.preproc.shifting import truncate, pad, timeshift, freqshift, shiftToRef
from fsl_mrs.utils.preproc.filtering import apodize
from fsl_mrs.utils.preproc.remove import hlsvd
from fsl_mrs.utils.preproc.general import add,subtract
from fsl_mrs.utils.preproc.unlike import identifyUnlikeFIDs
\ No newline at end of file
from fsl_mrs.utils.preproc.general import add, subtract
from fsl_mrs.utils.preproc.unlike import identifyUnlikeFIDs
#!/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
# Copyright (C) 2019 University of Oxford
# SHBASECOPYRIGHT
from jinja2 import FileSystemLoader, Environment
import os.path as op
from dataclasses import dataclass
from datetime import datetime
templatePath = op.join(op.dirname(__file__),'templates')
templatePath = op.join(op.dirname(__file__), 'templates')
@dataclass
class figgroup:
'''Keep figure data together'''
fig: str = ''
foretext: str = ''
afttext: str =''
afttext: str = ''
name: str = ''
def plotStyles():
# colors = {'in':'rgb(67,67,67)',
'''Return plot styles'''
# colors = {'in':'rgb(67,67,67)',
# 'out':'rgb(0,0,255)',
# 'emph':'rgb(255,0,0)',
# 'diff':'rgb(0,255,0)'}
colors = {'in':'rgb(166,206,227)',
'out':'rgb(31,120,180)',
'emph':'rgb(251,154,153)',
'diff':'rgb(51,160,44)',
'spare':'rgb(178,223,138)',
'blk':'rgb(0,0,0)'}
line_size = {'in':2,
'out':2,
'emph':2,
'diff':2,
'spare':2,
'blk':2}
colors = {'in': 'rgb(166,206,227)',
'out': 'rgb(31,120,180)',
'emph': 'rgb(251,154,153)',
'diff': 'rgb(51,160,44)',
'spare': 'rgb(178,223,138)',
'blk': 'rgb(0,0,0)'}
line_size = {'in': 2,
'out': 2,
'emph': 2,
'diff': 2,
'spare': 2,
'blk': 2}
line = {}
for key in colors:
line.update({key:{'color':colors[key],'width':line_size[key]}})
line.update({key: {'color': colors[key],
'width': line_size[key]}})
return line,colors,line_size
return line, colors, line_size
def plotAxesStyle(fig,ppmlim,title=None):
def plotAxesStyle(fig, ppmlim, title=None):
if ppmlim is not None:
fig.layout.xaxis.update(title_text='Chemical shift (ppm)',
tick0=2, dtick=.5,
range=[ppmlim[1],ppmlim[0]])
else:
range=[ppmlim[1], ppmlim[0]])
else:
fig.layout.xaxis.update(title_text='Chemical shift (ppm)',
tick0=2, dtick=.5)
fig.layout.yaxis.update(zeroline=True,
zerolinewidth=1,
zerolinecolor='Gray',
showgrid=False,showticklabels=False)
fig.layout.yaxis.update(zeroline=True,
zerolinewidth=1,
zerolinecolor='Gray',
showgrid=False,
showticklabels=False)
if title is not None:
fig.layout.update({'title': title})
fig.update_layout(template = 'plotly_white')
fig.update_layout(template='plotly_white')
def singleReport(outfile,opName,headerinfo,figurelist):
def singleReport(outfile, opName, headerinfo, figurelist):
"""
Entry point for the script.
Render a template and write it to file.
......@@ -77,7 +82,7 @@ def singleReport(outfile,opName,headerinfo,figurelist):
figure_section_template = env.get_template("figure_section.html")
hdr_section_template = env.get_template("header_section.html")
op_section_template = env.get_template("operation_section.html")
# Content to be published
datestr = datetime.now().strftime("%Y-%m-%d %H:%M")
title = f"Report for {opName} - {datestr}"
......@@ -86,22 +91,22 @@ def singleReport(outfile,opName,headerinfo,figurelist):
figsections = []
for figs in figurelist:
figsections.append(figure_section_template.render(
figName = figs.name,
foretext = figs.foretext,
figure = figs.fig,
afttext = figs.afttext))
figName=figs.name,
foretext=figs.foretext,
figure=figs.fig,
afttext=figs.afttext))
hdr = hdr_section_template.render(hdrName = opName+'_hdr',hdrText=headerinfo)
hdr = hdr_section_template.render(hdrName=opName + '_hdr',
hdrText=headerinfo)
sections = []
sections.append(op_section_template.render(
opName=opName,
header_sec=hdr,
fig_sections=figsections
))
))
with open(outfile, "w") as f:
f.write(base_template.render(
f.write(base_template.render(
title=title,
sections=sections
))
sections=sections))
......@@ -66,7 +66,7 @@ def shiftToRef(FID, target, bw, cf, nucleus='1H', ppmlim=(2.8, 3.2), shift=True)
:param bool shift: If True (default) ppm values include shift
:return: Shifted FID
:return: Shifted amount in ppm
:return: Shifted amount in ppm
'''
# Find maximum of absolute spectrum in ppm limit
......
......@@ -10,6 +10,7 @@ parentdir_prefix =
ignore =
# Multiple spaces before operator
E221
W503
per-file-ignores =
__init__.py:F401
exclude =
......
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