├── .gitignore
├── CTrecon.m
├── CTsimulation.m
├── IO
├── cfgmatchrule.m
├── checkrawfile.m
├── cleanpath.m
├── clearbincfg.m
├── decodenumber.m
├── dicommeta.m
├── external
│ └── extrernal
├── general
│ ├── jsonformat.m
│ ├── jsonread.m
│ ├── jsonwrite.m
│ ├── myxml2struct.m
│ └── struct2xml.m
├── loadbindata.m
├── loaddata.m
├── loaddicomimg.m
├── packstruct.m
├── readcfgfile.m
├── sparsepack.m
├── standard
│ ├── air_corr_v1.0.xml
│ ├── air_corr_v1.10.xml
│ ├── beamharden_corr_v1.0.xml
│ ├── beamharden_corr_v1.11.xml
│ ├── beamharden_corr_v1.12.xml
│ ├── beamharden_corr_v2.0.xml
│ ├── boneharden_corr_v1.0.xml
│ ├── boneharden_corr_v1.12.xml
│ ├── bowtie_corr_v1.0.xml
│ ├── corrbase.xml
│ ├── crosstalk_corr_v1.0.xml
│ ├── crosstalk_corr_v1.11.xml
│ ├── detector_corr_v1.0.xml
│ ├── detector_corr_v1.11.xml
│ ├── detectorextra_corr_v1.0.xml
│ ├── hounsefield_corr_v1.0.xml
│ ├── idealwater_corr_v1.0.xml
│ ├── iteration_corr_v1.0.xml
│ ├── iteration_corr_v1.1.xml
│ ├── materialdecomp_corr_v1.0.xml
│ ├── nonlinear_corr_v1.0.xml
│ ├── nonlinear_corr_v1.11.xml
│ ├── offfocal_corr_v1.0.xml
│ ├── offfocal_corr_v2.0.xml
│ ├── rawdata_v1.0.xml
│ ├── rawdatabase.xml
│ └── tube_corr_v1.0.xml
├── struct2binfile.m
├── structbincfg.m
└── subconfigure.m
├── LICENSE
├── README.md
├── cali
├── aircalibration.m
├── calicorrprepare.m
├── calidataprepare.m
├── caliprmforcorr.m
├── calixml
│ ├── Aircali_sample.xml
│ ├── BHcali_sample.xml
│ ├── Zcali_sample.xml
│ ├── corrcouple_sample.xml
│ ├── protocol_beamharden.xml
│ └── protocol_nonlinear.xml
├── collimatedcorr.m
├── corrcouplerule.m
├── experiment
│ ├── bfbacktobh_test1.m
│ ├── bladeexperiment.m
│ ├── bladeexperiment2.m
│ ├── bowtieexperiment.m
│ ├── expbfback_test1.m
│ ├── loadraw_scp1.m
│ ├── loadraw_scp2.m
│ ├── spectfit_test1.m
│ ├── spectfitfun.m
│ └── testdata
│ │ └── response_1219.mat
├── focalspot20x.m
├── lib
│ ├── invpolyval.m
│ ├── iterinvpolyval.m
│ ├── iterpolyval.m
│ ├── pinleftoptmatrix.m
│ ├── pinprojectfun.m
│ ├── pinsplines.m
│ ├── polyval2dm.m
│ ├── polyval3dm.m
│ ├── ppcenterderivative.m
│ ├── ppweightcenter.m
│ ├── translatefillup.m
│ └── translatefillup_back.m
├── offfocalloadkernel.m
├── parameterforcorr.m
├── pindetcalibration.m
├── simuAircali.m
├── simuBHcali.m
├── simuBHcali2.m
├── simuBonehardencali.m
└── simuBonehardencali2.m
├── doc
├── UserGuide.html
├── fig
│ └── addtool1.png
└── html
│ ├── configurethereconpipeline.html
│ ├── configurethesimulation.html
│ ├── protocolandnamerule.html
│ ├── quickstart.html
│ └── systemandsystemdatafiles.html
├── geometry
├── fillupobject.m
├── homotopy
│ ├── S3renormalize.m
│ ├── cylinderconecut.m
│ ├── samplesetinobject.m
│ └── square2circle.m
├── intersection.m
├── intersection
│ ├── linesinimage2D.m
│ ├── linesinimage2Dmosaic.m
│ ├── linesinimage3D.m
│ ├── linesinimage3Dmosaic.m
│ ├── linesinimageLI2D.m
│ ├── linesinimageLI2D2.m
│ ├── linesinobject.m
│ ├── multiinsect.m
│ ├── parallelcrossprojectimg2D.m
│ ├── parallellinearinterp2D.m
│ ├── parallellinearinterp2D2.m
│ ├── parallellinearinterp3D.m
│ ├── parallellinearinterp3D2.m
│ ├── parallellinearinterp3D3.m
│ ├── parallelprojinimage.m
│ └── projectioninimage.m
├── lib
│ ├── ASGmodel.m
│ ├── defaultvolume.m
│ ├── objectrotation.m
│ ├── pararea.m
│ ├── pararea2.m
│ ├── polar2xyz.m
│ ├── square2circle.m
│ └── xyz2polar.m
├── objectvisual.m
├── ppcenterderivative.m
├── ppweightcenter.m
├── prepareasgdata.m
├── samplesetinobject.m
└── visual
│ ├── objectmeshgrid.m
│ └── tetrahedmesh.m
├── physics
├── airprojection.m
├── detectorslicemerge.m
├── effectZandMass.m
├── equivalentthickness.m
├── flewoverbowtie.m
├── loadmaterial.m
├── materialdefine.m
├── matter
│ ├── elements
│ │ ├── Ac.csv
│ │ ├── Ac.txt
│ │ ├── Ag.csv
│ │ ├── Ag.txt
│ │ ├── Al.csv
│ │ ├── Al.txt
│ │ ├── Ar.csv
│ │ ├── Ar.txt
│ │ ├── As.csv
│ │ ├── As.txt
│ │ ├── At.csv
│ │ ├── At.txt
│ │ ├── Au.csv
│ │ ├── Au.txt
│ │ ├── B.csv
│ │ ├── B.txt
│ │ ├── Ba.csv
│ │ ├── Ba.txt
│ │ ├── Be.csv
│ │ ├── Be.txt
│ │ ├── Bi.csv
│ │ ├── Bi.txt
│ │ ├── Br.csv
│ │ ├── Br.txt
│ │ ├── C.csv
│ │ ├── C.txt
│ │ ├── Ca.csv
│ │ ├── Ca.txt
│ │ ├── Cd.csv
│ │ ├── Cd.txt
│ │ ├── Ce.csv
│ │ ├── Ce.txt
│ │ ├── Cl.csv
│ │ ├── Cl.txt
│ │ ├── Co.csv
│ │ ├── Co.txt
│ │ ├── Cr.csv
│ │ ├── Cr.txt
│ │ ├── Cs.csv
│ │ ├── Cs.txt
│ │ ├── Cu.csv
│ │ ├── Cu.txt
│ │ ├── Dy.csv
│ │ ├── Dy.txt
│ │ ├── Er.csv
│ │ ├── Er.txt
│ │ ├── Eu.csv
│ │ ├── Eu.txt
│ │ ├── F.csv
│ │ ├── F.txt
│ │ ├── Fe.csv
│ │ ├── Fe.txt
│ │ ├── Fr.csv
│ │ ├── Fr.txt
│ │ ├── Ga.csv
│ │ ├── Ga.txt
│ │ ├── Gd.csv
│ │ ├── Gd.txt
│ │ ├── Ge.csv
│ │ ├── Ge.txt
│ │ ├── H.csv
│ │ ├── H.txt
│ │ ├── He.csv
│ │ ├── He.txt
│ │ ├── Hf.csv
│ │ ├── Hf.txt
│ │ ├── Hg.csv
│ │ ├── Hg.txt
│ │ ├── Ho.csv
│ │ ├── Ho.txt
│ │ ├── HubbellTableI.csv
│ │ ├── I.csv
│ │ ├── I.txt
│ │ ├── In.csv
│ │ ├── In.txt
│ │ ├── Ir.csv
│ │ ├── Ir.txt
│ │ ├── K.csv
│ │ ├── K.txt
│ │ ├── Kr.csv
│ │ ├── Kr.txt
│ │ ├── La.csv
│ │ ├── La.txt
│ │ ├── Li.csv
│ │ ├── Li.txt
│ │ ├── Lu.csv
│ │ ├── Lu.txt
│ │ ├── Mg.csv
│ │ ├── Mg.txt
│ │ ├── Mn.csv
│ │ ├── Mn.txt
│ │ ├── Mo.csv
│ │ ├── Mo.txt
│ │ ├── N.csv
│ │ ├── N.txt
│ │ ├── Na.csv
│ │ ├── Na.txt
│ │ ├── Nb.csv
│ │ ├── Nb.txt
│ │ ├── Nd.csv
│ │ ├── Nd.txt
│ │ ├── Ne.csv
│ │ ├── Ne.txt
│ │ ├── Ni.csv
│ │ ├── Ni.txt
│ │ ├── O.csv
│ │ ├── O.txt
│ │ ├── Os.csv
│ │ ├── Os.txt
│ │ ├── P.csv
│ │ ├── P.txt
│ │ ├── Pa.csv
│ │ ├── Pa.txt
│ │ ├── Pb.csv
│ │ ├── Pb.txt
│ │ ├── Pd.csv
│ │ ├── Pd.txt
│ │ ├── Pm.csv
│ │ ├── Pm.txt
│ │ ├── Po.csv
│ │ ├── Po.txt
│ │ ├── Pr.csv
│ │ ├── Pr.txt
│ │ ├── Pt.csv
│ │ ├── Pt.txt
│ │ ├── Ra.csv
│ │ ├── Ra.txt
│ │ ├── Rb.csv
│ │ ├── Rb.txt
│ │ ├── Re.csv
│ │ ├── Re.txt
│ │ ├── Rh.csv
│ │ ├── Rh.txt
│ │ ├── Rn.csv
│ │ ├── Rn.txt
│ │ ├── Ru.csv
│ │ ├── Ru.txt
│ │ ├── S.csv
│ │ ├── S.txt
│ │ ├── Sb.csv
│ │ ├── Sb.txt
│ │ ├── Sc.csv
│ │ ├── Sc.txt
│ │ ├── Se.csv
│ │ ├── Se.txt
│ │ ├── Si.csv
│ │ ├── Si.txt
│ │ ├── Sm.csv
│ │ ├── Sm.txt
│ │ ├── Sn.csv
│ │ ├── Sn.txt
│ │ ├── Sr.csv
│ │ ├── Sr.txt
│ │ ├── Ta.csv
│ │ ├── Ta.txt
│ │ ├── Tb.csv
│ │ ├── Tb.txt
│ │ ├── Tc.csv
│ │ ├── Tc.txt
│ │ ├── Te.csv
│ │ ├── Te.txt
│ │ ├── Th.csv
│ │ ├── Th.txt
│ │ ├── Ti.csv
│ │ ├── Ti.txt
│ │ ├── Tl.csv
│ │ ├── Tl.txt
│ │ ├── Tm.csv
│ │ ├── Tm.txt
│ │ ├── V.csv
│ │ ├── V.txt
│ │ ├── W.csv
│ │ ├── W.txt
│ │ ├── Xe.csv
│ │ ├── Xe.txt
│ │ ├── Y.csv
│ │ ├── Y.txt
│ │ ├── Yb.csv
│ │ ├── Yb.txt
│ │ ├── Zn.csv
│ │ ├── Zn.txt
│ │ ├── Zr.csv
│ │ └── Zr.txt
│ ├── getdatafromNIST.py
│ ├── loadmaterialsample.m
│ └── material
│ │ ├── 93WNiFe.cfg
│ │ ├── 97WNiFe.cfg
│ │ ├── Alcohol.cfg
│ │ ├── CorticalBone.cfg
│ │ ├── CorticalBone_ICRP.cfg
│ │ ├── Cranium.cfg
│ │ ├── FAPbI3.cfg
│ │ ├── Gd2O2S.cfg
│ │ ├── HA.cfg
│ │ ├── MAPbBr3.cfg
│ │ ├── PE.cfg
│ │ ├── PMMA.cfg
│ │ ├── PVC.cfg
│ │ ├── Sulfur.cfg
│ │ ├── air.cfg
│ │ ├── carbonfiber.cfg
│ │ ├── crystalSi.cfg
│ │ ├── foamedPE.cfg
│ │ ├── graphite.cfg
│ │ ├── metalAg.cfg
│ │ ├── metalAl.cfg
│ │ ├── metalCU.cfg
│ │ ├── metalPb.cfg
│ │ ├── metalTi.cfg
│ │ ├── metalW.cfg
│ │ ├── steel301.cfg
│ │ ├── teflon.cfg
│ │ ├── vacuum.cfg
│ │ ├── water.cfg
│ │ ├── water1100.cfg
│ │ └── water2000.cfg
├── mergedetector.m
├── offfocalpseudoscan.m
├── offfocalpseudoscan2.m
├── photon2electron.m
├── projectinphantom.m
├── projectionscan.m
├── projectionscan2.m
├── projectionscan2b.m
├── scanprepare.m
├── spectrumresample.m
├── tube
│ ├── 100kVp.csv
│ ├── 120kVp.csv
│ ├── 140kVp.csv
│ ├── 70-150
│ │ ├── 100kVp.csv
│ │ ├── 105kVp.csv
│ │ ├── 110kVp.csv
│ │ ├── 115kVp.csv
│ │ ├── 120kVp.csv
│ │ ├── 125kVp.csv
│ │ ├── 130kVp.csv
│ │ ├── 135kVp.csv
│ │ ├── 140kVp.csv
│ │ ├── 145kVp.csv
│ │ ├── 150kVp.csv
│ │ ├── 160kVp.csv
│ │ ├── 70kVp.csv
│ │ ├── 75kVp.csv
│ │ ├── 80kVp.csv
│ │ ├── 85kVp.csv
│ │ ├── 90kVp.csv
│ │ └── 95kVp.csv
│ ├── 80kVp.csv
│ ├── loadsourcespectrumsample.m
│ ├── tube_spectrumdata2_v1.0.corr
│ ├── tube_spectrumdata_60-150_v1.0.corr
│ ├── tube_spectrumdata_60-160_v1.0.corr
│ ├── tube_spectrumdata_70-150_v1.0.corr
│ └── tube_spectrumdata_v1.0.corr
└── weightofslicemerge.m
├── recon
├── external
│ ├── reconnode_CRISAxialBackprojection.m
│ ├── reconnode_CRISAxialFBP.m
│ └── reconnode_CRISofffocalcali.m
├── lib
│ ├── DFSmidchannel.m
│ ├── QDOorder.m
│ ├── TV
│ │ ├── BregmanTV2D.m
│ │ ├── BregmanTV2DL.m
│ │ ├── BregmanTV2D_oneway.m
│ │ ├── BregmanTV2D_tanh.m
│ │ ├── BregmanTV2Db0.m
│ │ ├── BregmanTV2Db1.m
│ │ ├── BregmanTV2Db2.m
│ │ ├── BregmanTV3D.m
│ │ ├── BregmanTV3D_axialiter.m
│ │ ├── BregmanTV3D_helicaliter.m
│ │ ├── BregmanTV3D_tanh.m
│ │ ├── BregmanTV_Z.m
│ │ ├── GlogTV1D.m
│ │ ├── GlogTV1D2.m
│ │ ├── LaplacedTV1D.m
│ │ ├── LaplacedTV1D2.m
│ │ ├── LaplacianSmooth_3Dtanh.m
│ │ └── TVoptions.m
│ ├── ZetaEta2TzTable.m
│ ├── Zupsamplingprepare.m
│ ├── aircorrection
│ │ ├── aircorrwithoutref.m
│ │ ├── airrefcorr.m
│ │ ├── airreference.m
│ │ ├── intensityaircorr.m
│ │ ├── isrefblocked.m
│ │ └── referencecorr.m
│ ├── antiringonhelical.m
│ ├── antiringonimage.m
│ ├── axialchordhomeomorph.m
│ ├── axialconehomeomorph.m
│ ├── backprojection
│ │ ├── axial3Dprepare.m
│ │ ├── cradleprepare.m
│ │ ├── helicalbpinterp.m
│ │ ├── helicalprepare.m
│ │ └── helicalviewexta.m
│ ├── bonecorrEdgeEnhance.m
│ ├── bonecorrEdgeEnhance3D.m
│ ├── commonbpprepare.m
│ ├── detpos2angle.m
│ ├── detpos2fanangles.m
│ ├── doubleup.m
│ ├── doubleup2.m
│ ├── doubleupbutterfly.m
│ ├── filterdesign.m
│ ├── fpprepare.m
│ ├── getBoneImg.m
│ ├── getDicominfo.m
│ ├── helicalrthetainv.m
│ ├── helicalrthetatrans.m
│ ├── idealfanangles.m
│ ├── imagereorder.m
│ ├── loadboneharden.m
│ ├── loadfilter.m
│ ├── ntimesup.m
│ ├── ntimesupmatrix.m
│ ├── offfocal
│ │ ├── offfocalsinckernel.m
│ │ ├── offfocalzcross.m
│ │ └── offfocalzcrossmatrix.m
│ ├── omiga4interp.m
│ ├── omiga4table.m
│ ├── rebin
│ │ ├── rebinprepare.m
│ │ └── sloperebinprepare.m
│ ├── recon
│ │ ├── initialimagehead.m
│ │ └── reconimagehead.m
│ ├── rthetainv.m
│ └── rthetatrans.m
├── nodes
│ ├── loadcalitables.m
│ ├── pipelineinitial.m
│ ├── reconinitial.m
│ ├── reconnode_Antiring.m
│ ├── reconnode_Antiwindmill.m
│ ├── reconnode_Axial2DBackprojection.m
│ ├── reconnode_Axial3DBackprojection.m
│ ├── reconnode_Axialrebin.m
│ ├── reconnode_Backprojection.m
│ ├── reconnode_Filter.m
│ ├── reconnode_HelicalBackprojection.m
│ ├── reconnode_HelicalPiLineBP.m
│ ├── reconnode_Helicalrebin.m
│ ├── reconnode_Rebin.m
│ ├── reconnode_Rowcombine.m
│ ├── reconnode_aircali.m
│ ├── reconnode_aircorr.m
│ ├── reconnode_badchannelcorr.m
│ ├── reconnode_ballcali.m
│ ├── reconnode_beamhardencali.m
│ ├── reconnode_beamhardencorr.m
│ ├── reconnode_bonehardencali.m
│ ├── reconnode_bonehardencorr.m
│ ├── reconnode_crosstalkcali.m
│ ├── reconnode_crosstalkcorr.m
│ ├── reconnode_detectorcali.m
│ ├── reconnode_fananglecorr.m
│ ├── reconnode_hounsefieldcorr.m
│ ├── reconnode_idealwater.m
│ ├── reconnode_inverserebin.m
│ ├── reconnode_log2.m
│ ├── reconnode_nonlinearcali.m
│ ├── reconnode_nonlinearcorr.m
│ ├── reconnode_offfocalcali.m
│ ├── reconnode_offfocalcorr.m
│ ├── reconnode_readrawdata.m
│ ├── reconnode_referencecorr.m
│ └── reconnode_watergoback.m
├── nodesentry.m
├── pipelinelib
│ ├── allpurposenodes
│ │ ├── allpurposefakekernel.m
│ │ └── fakenodereadrawdata.m
│ ├── branchpooltrace.m
│ ├── combinenodes.m
│ ├── defaultpipelineprepare.m
│ ├── indexinoutmap.m
│ ├── initialpool.m
│ ├── inputbranchpool.m
│ ├── movepointsaftercopy.m
│ ├── nodepoststep.m
│ ├── nodepriostep.m
│ ├── nodestatecheck.m
│ ├── outputbranchpool.m
│ ├── pipereadingnumer.m
│ ├── poolclear.m
│ ├── pooldatacopy.m
│ ├── pooldataoutput.m
│ ├── poolhardcopy.m
│ ├── poolindex.m
│ ├── poolmirror.m
│ ├── poolpriostep.m
│ ├── poolpspaceleft.m
│ ├── poolreadable.m
│ ├── poolrecycle.m
│ ├── poolrecycle2.m
│ ├── poolresize.m
│ ├── pooltrace.m
│ └── we shall move the pool things to a class.txt
├── prepare
│ ├── reconnode_airprepare.m
│ ├── reconnode_allpurposeprepare.m
│ ├── reconnode_antiringprepare.m
│ ├── reconnode_antiwindmillprepare.m
│ ├── reconnode_axial3dbackprojectionprepare.m
│ ├── reconnode_axialrebinprepare.m
│ ├── reconnode_backprojectionprepare.m
│ ├── reconnode_backprojectionrestart.m
│ ├── reconnode_badchannelprepare.m
│ ├── reconnode_databufferprepare.m
│ ├── reconnode_dataoutputprepare.m
│ ├── reconnode_datareloadprepare.m
│ ├── reconnode_donothingprepare.m
│ ├── reconnode_fanangleprepare.m
│ ├── reconnode_filterprepare.m
│ ├── reconnode_helicalbackprojectionprepare.m
│ ├── reconnode_helicalbackprojectionrestart.m
│ ├── reconnode_helicalrebinprepare.m
│ ├── reconnode_loadrawdataprepare.m
│ ├── reconnode_loadrawdatarestart.m
│ ├── reconnode_log2prepare.m
│ ├── reconnode_multiaxialmeanprepare.m
│ ├── reconnode_offfocalprepare.m
│ ├── reconnode_pipelineprepare.m
│ ├── reconnode_pipelinerestart.m
│ ├── reconnode_pipelinestuckprepare.m
│ ├── reconnode_rebinprepare.m
│ ├── reconnode_rebinrestart.m
│ ├── reconnode_referenceprepare.m
│ └── reconnode_upsampleprepare.m
├── recon_access.m
└── supportnodes
│ ├── reconnode_Systemconfigure.m
│ ├── reconnode_allpurpose.m
│ ├── reconnode_corrclear.m
│ ├── reconnode_corrdrawback.m
│ ├── reconnode_corrredirect.m
│ ├── reconnode_databackup.m
│ ├── reconnode_databuffer.m
│ ├── reconnode_dataclear.m
│ ├── reconnode_datadelete.m
│ ├── reconnode_datamean.m
│ ├── reconnode_dataoutput.m
│ ├── reconnode_datareload.m
│ ├── reconnode_disguiser.m
│ ├── reconnode_donothing.m
│ ├── reconnode_error.m
│ ├── reconnode_flow2workspace.m
│ ├── reconnode_funhandle.m
│ ├── reconnode_multiaxialmean.m
│ ├── reconnode_null.m
│ ├── reconnode_pipelinedatamove.m
│ ├── reconnode_pipelinestuck.m
│ ├── reconnode_simulation.m
│ └── reconnode_sleep.m
├── scripts
├── BoneBHCorrectionScript_3Dfit.m
├── BoneBHCorrectionScript_surffit.m
├── BoneBHcali_script.m
├── BoneBHcali_script_ForSimudata.m
├── _to release informal workflows in here
├── aircali_script.m
├── airrepeat_script.m
├── bnc3in1cali_dataprepare.m
├── bnc3in1cali_step1.m
├── bnc3in1cali_step2.m
├── bnc3in1cali_step2_70KV.m
├── bnc3in1cali_step2_bk.m
├── bnc3in1cali_step2_crs1.m
├── bnc3in1cali_step2_crs2.m
├── bnc3in1cali_step3.m
├── bnc3in1cali_step3_70KV.m
├── bowtieframe_script.m
├── corrformatbase_script.m
├── cutshots_script.m
├── detectorframe_script.m
├── nonliearcali_script.m
├── nonlinearcali_script.m
├── pincali_script.m
├── projection_script.m
├── rawdataframe_script.m
├── recon_script_demo.m
├── systemconfigure_script.m
├── tubeframe_script.m
└── zmappalette_script.m
├── system
├── collimatorexposure.m
├── configureclean.m
├── datapath
│ ├── corrtableoutput.m
│ ├── rawdataoutput.m
│ ├── reconxmloutput.m
│ └── simuresultsoutput.m
├── detectorextracollim.m
├── initialGPU.m
├── initialstatus.m
├── loadmodconfig.m
├── loadprotocol.m
├── materialconfigure.m
├── mod
│ ├── BoneBH_configure.xml
│ ├── bowtieframe
│ │ ├── bowtie_sample_v1.0.corr
│ │ ├── bowtiecurvesample.m
│ │ └── bowtiesample.m
│ ├── console
│ │ ├── sample_corrcouplerule.xml
│ │ ├── sample_corrcouplerule2.xml
│ │ ├── sample_filenamerule.xml
│ │ └── sample_filenamerule2.xml
│ ├── detectorframe
│ │ ├── collimatorexplain_unit24.xml
│ │ ├── collimatorexplain_unit64.xml
│ │ ├── detector_sample_unit16.corr
│ │ ├── detector_sample_unit24.corr
│ │ ├── detector_sample_unit64_v1.0.corr
│ │ ├── detector_sample_v1.0.corr
│ │ ├── detectorframe.rar
│ │ ├── detectorpos_ideal_1000.mat
│ │ └── idealdetector.m
│ ├── phantom
│ │ ├── phantom_Cublade1mm.xml
│ │ ├── phantom_Head_Cranium_170_center.xml
│ │ ├── phantom_Head_Cranium_170_center_10mm.xml
│ │ ├── phantom_Head_Cranium_170_center_4mm.xml
│ │ ├── phantom_Head_Cranium_170_center_8mm.xml
│ │ ├── phantom_air.xml
│ │ ├── phantom_heart_of_oak.json
│ │ ├── phantom_heart_of_oak.xml
│ │ ├── phantom_shellwater200_center.xml
│ │ ├── phantom_shellwater200_off120.xml
│ │ ├── phantom_shellwater200_off90.xml
│ │ ├── phantom_shellwater300_center.xml
│ │ ├── phantom_shellwater300_off120.xml
│ │ ├── phantom_shellwater300_off90.xml
│ │ ├── phantom_stealball.xml
│ │ ├── phantom_water200_center.xml
│ │ ├── phantom_water200_off20.xml
│ │ ├── phantom_water200_off90.xml
│ │ ├── phantom_water300_center.xml
│ │ └── phantom_water300_off90.xml
│ ├── phantom_water.xml
│ ├── protocol
│ │ ├── sample_protocol_Axial.xml
│ │ └── sample_protocol_Helical.xml
│ ├── rawdataframe
│ │ ├── rawdata_sample.raw
│ │ ├── rawdata_sample0.raw.xml
│ │ └── rawdata_sample1.raw.xml
│ ├── recon
│ │ ├── iteration
│ │ │ ├── reconAxialiter_configure_samp.xml
│ │ │ ├── reconHelicaliter_configure_samp.xml
│ │ │ ├── recon_Axial_Iteration_old.xml
│ │ │ └── recon_Helical_Iteration_old.xml
│ │ ├── recon_Axial_sample.xml
│ │ ├── recon_Axial_sample2.xml
│ │ ├── recon_Helical_sample.xml
│ │ ├── recon_Helical_sample2.xml
│ │ └── reconsystem_sample.xml
│ ├── sample_configure.xml
│ ├── sample_configure_expand.xml
│ ├── sample_output_configure.xml
│ ├── sample_phantom.json
│ ├── sample_phantom.xml
│ ├── sample_protocol.xml
│ └── sample_system.xml
├── nametagrule.m
├── phantomcfgsample.m
├── phantomconfigure.m
├── protocol2nametag.m
├── protocolcfgsample.m
├── protocolconfigure.m
├── systemcfgsample.m
├── systemconfigure.m
└── systemprepare.m
└── tools
├── almostlsq.m
├── backup
├── struct2xml_backup1.m
└── xml2struct_backup1.m
├── castuint8.m
├── classGPU.m
├── classsize.m
├── cleaninputarg.m
├── cttool.m
├── cttool
├── +cttool
│ ├── +iptui
│ │ ├── +internal
│ │ │ ├── myfilterWorkspaceVars.m
│ │ │ └── myimgetvar.m
│ │ └── imagePage.m
│ ├── cttool.m
│ ├── imcttool.m
│ ├── myimcontrast.m
│ └── myimdisplayrange.m
├── +cttool_2016
│ ├── +iptui
│ │ ├── +internal
│ │ │ ├── myfilterWorkspaceVars.m
│ │ │ └── myimgetvar.m
│ │ └── imagePage.m
│ ├── cttool.m
│ ├── imcttool.m
│ ├── imdisplayrange.m
│ ├── myimcontrast.m
│ └── myimdisplayrange.m
└── images
│ ├── leftarrow.png
│ └── rightarrow.png
├── curves
├── acot2.m
├── hardentanh.m
├── hardentanh2.m
├── mylorenzcurve.m
└── slidecurve.m
├── everything2real.m
├── everything2single.m
├── fileposorgtoend.m
├── findfield.m
├── findfields.m
├── gaussblur.m
├── getstructptr.m
├── gpuArraygroup.m
├── hsl2hsv.m
├── hsl2rgb.m
├── ilovedot.m
├── imagedown.m
├── imageup2.m
├── imageupn.m
├── imageupnGPU.m
├── interpprepare.m
├── isFFF.m
├── isavail.m
├── lgwt.m
├── lgwt_license.txt
├── linkstringcell.m
├── natsort.m
├── natsortfiles.m
├── putfieldsinGPU.m
├── putinGPU.m
├── real2complex.m
├── splaplace2D.m
├── splitcomma.m
├── struct2ptr.m
├── structcellcurse.m
├── structcompare.m
├── structmerge.m
├── structregexprep.m
├── structstrreplace.m
├── tac.m
├── uint8cast.m
├── whatisfft.m
└── xml2json.m
/.gitignore:
--------------------------------------------------------------------------------
1 | /CRISrecon.m
2 | /IO/external/*/
3 | /advance/*
4 | /test/*
5 | /CUDA/*
6 |
7 | # ---> MATLAB
8 | # Windows default autosave extension
9 | *.asv
10 |
11 | # OSX / *nix default autosave extension
12 | *.m~
13 |
14 | # Compiled MEX binaries (all platforms)
15 | *.mex*
16 |
17 | # Packaged app and toolbox files
18 | *.mlappinstall
19 | *.mltbx
20 |
21 | # Generated helpsearch folders
22 | helpsearch*/
--------------------------------------------------------------------------------
/IO/cleanpath.m:
--------------------------------------------------------------------------------
1 | function configure = cleanpath(configure, mainpath, escapepath)
2 | % clean the pathes
3 |
4 | if nargin < 3
5 | escapepath = 'system.path';
6 | end
7 |
8 | % to replace relative pathes ~/ and ~\ by mainpath
9 | configure = structregexprep(configure, '~(/|\\)', regexptranslate('escape', mainpath));
10 | % to replace relative pathes $pathname$ by configure.system.path.(pathname)
11 | configure = structregexprep(configure, '\$(\w*)(?=(\\|/))', ['${regexptranslate(''escape'', root.' escapepath '.($1))}']);
12 | % kown bug: \. -> . , \- -> -
13 | configure = structregexprep(configure, '\\([\-,\.])', '$1');
14 | % kown bug: \ -> \\
15 | configure = structregexprep(configure, '(?!^)\\+', '\\');
16 |
17 | end
--------------------------------------------------------------------------------
/IO/decodenumber.m:
--------------------------------------------------------------------------------
1 | function r = decodenumber(c, Sorig, Sprev)
2 | % a subfunction to explain the numers in cfg_ii.size and cfg_ii.number used in sparsepack.m and packstruct.m
3 |
4 | if nargin < 3
5 | Sprev = Sorig;
6 | end
7 |
8 | if isnumeric(c)
9 | r = c;
10 | elseif isempty(c)
11 | r = [];
12 | elseif ischar(c)
13 | % c(c=='$') = 'S';
14 | c = regexprep(c, '\$\$' , 'Sorig');
15 | c = regexprep(c, '\$' , 'Sprev');
16 | try
17 | r = eval(c);
18 | catch
19 | r = c;
20 | end
21 | else
22 | r = nan;
23 | end
24 | % to double
25 | if isnumeric(r)
26 | r = double(r);
27 | end
28 |
29 | end
--------------------------------------------------------------------------------
/IO/external/extrernal:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dier3486/CT-simulation/59b8caefab024554a6d8f7a45a0f038306115747/IO/external/extrernal
--------------------------------------------------------------------------------
/IO/general/jsonread.m:
--------------------------------------------------------------------------------
1 | function jstruct = jsonread(fname)
2 | % read json file
3 |
4 | f1 = fopen(fname, 'r');
5 | charf1 = fread(f1, inf, 'char=>char');
6 | fclose(f1);
7 | jstruct = jsondecode(charf1(:)');
8 |
--------------------------------------------------------------------------------
/IO/general/jsonwrite.m:
--------------------------------------------------------------------------------
1 | function jschar = jsonwrite(jstruct, fname)
2 | % write json file
3 | % jschar = jsonwrite(jstruct, fname);
4 |
5 | jstruct = jsonclear(jstruct);
6 | jschar = jsonformat(jsonencode(jstruct));
7 |
8 | if nargin > 1
9 | f1 = fopen(fname, 'w');
10 | if f1>=0
11 | fwrite(f1, jschar);
12 | end
13 | if f1>=3
14 | fclose(f1);
15 | end
16 | end
17 |
18 | end
19 |
20 | function S = jsonclear(S)
21 |
22 | for fields = fieldnames(S)'
23 | if isgpuarray(S.(fields{1}))
24 | S.(fields{1}) = gather(S.(fields{1}));
25 | end
26 | if isstruct(S.(fields{1}))
27 | for ii = 1:length(S.(fields{1})(:))
28 | S.(fields{1})(ii) = jsonclear(S.(fields{1})(ii));
29 | end
30 | elseif iscell(S.(fields{1}))
31 | for ii = 1:length(S.(fields{1})(:))
32 | S.(fields{1}){ii} = jsonclear(S.(fields{1}){ii});
33 | end
34 | else
35 | switch class(S.(fields{1}))
36 | case 'function_handle'
37 | S.(fields{1}) = char(S.(fields{1}));
38 | otherwise
39 | end
40 | end
41 | end
42 |
43 | end
--------------------------------------------------------------------------------
/IO/loadbindata.m:
--------------------------------------------------------------------------------
1 | function [datastruct, cfg] = loadbindata(datafile, cfgfile, warnonoff)
2 | % load bin data file
3 |
4 | if nargin<3
5 | warnonoff = true;
6 | end
7 |
8 | if isstruct(cfgfile)
9 | cfg = cfgfile;
10 | elseif isfile(cfgfile)
11 | cfg = readcfgfile(cfgfile);
12 | elseif exist(cfgfile, 'file')
13 | if warnonoff
14 | warning('To load configure file in MATLAB search path! It might be unsafe.');
15 | end
16 | cfg = readcfgfile(cfgfile);
17 | else
18 | error('Can not open the cfgfile!');
19 | end
20 |
21 | fid = fopen(datafile, 'r');
22 |
23 | datastruct = sparsepack(fid, cfg);
24 | fclose(fid);
25 |
26 | end
27 |
--------------------------------------------------------------------------------
/IO/loaddicomimg.m:
--------------------------------------------------------------------------------
1 | function [img, dcminfo] = loaddicomimg(filepath, dcmext)
2 | % [img, dcminfo] = loaddicomimg(filepath, toclass)
3 | % load dicom image(s)
4 |
5 | if nargin<2
6 | dcmext = '.dcm';
7 | end
8 |
9 | if isfile(filepath)
10 | % read file
11 | dcminfo = dicominfo(filepath);
12 | img = dicomread(filepath);
13 | % to float
14 | img = single(img);
15 | % scale
16 | if isfield(dcminfo, 'RescaleIntercept')
17 | img = img.*dcminfo.RescaleSlope + dcminfo.RescaleIntercept + 1000;
18 | end
19 | elseif isfolder(filepath)
20 | [img, dcminfo] = loaddcmimage2(filepath, dcmext);
21 | else
22 | img = [];
23 | dcminfo = [];
24 | end
25 | end
26 |
27 |
28 | function [img, dcminfo] = loaddcmimage2(imgpath, dcmext)
29 |
30 | if nargin<2
31 | dcmext = '.dcm';
32 | end
33 |
34 | files = dir(fullfile(imgpath, [ '*' dcmext]));
35 | [~, sortidx] = natsortfiles({files.name});
36 | files = files(sortidx);
37 | Nf = size(files(:), 1);
38 |
39 | img = [];
40 | dcminfo = [];
41 | for ii = 1:Nf
42 | [img_ii, dcminfo_ii] = loaddicomimg(fullfile(files(ii).folder, files(ii).name));
43 | img = cat(4, img, img_ii);
44 | dcminfo = [dcminfo, dcminfo_ii];
45 | end
46 |
47 | end
--------------------------------------------------------------------------------
/IO/readcfgfile.m:
--------------------------------------------------------------------------------
1 | function cfg = readcfgfile(cfgfile)
2 |
3 | cfgfile = char(cfgfile);
4 | if exist(cfgfile, 'file')
5 | [~, ~, cfgext] = fileparts(cfgfile);
6 | switch cfgext
7 | case '.xml'
8 | root = myxml2struct(cfgfile);
9 | name = fieldnames(root);
10 | cfg = root.(name{1});
11 | case '.json'
12 | root = jsonread(cfgfile);
13 | name = fieldnames(root);
14 | cfg = root.(name{1});
15 | case '.mat'
16 | cfg = load(cfgfile);
17 | otherwise
18 | error(['Unknown file type ', cfgext]);
19 | end
20 | else
21 | error(['File not exist, ', cfgfile]);
22 | end
--------------------------------------------------------------------------------
/IO/standard/bowtie_corr_v1.0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 0
4 | Struct
5 |
6 | 1
7 |
8 | 0
9 | Uint8
10 | 4
11 | 1
12 |
13 |
14 | 4
15 | Single
16 | 3
17 | 4
18 |
19 |
20 | 16
21 | Single
22 | 1
23 | 4
24 |
25 |
26 | 20
27 | Uint32
28 | 1
29 | 4
30 |
31 |
32 | 24
33 | Uint32
34 | 1
35 | 4
36 |
37 |
38 | 512
39 | Single
40 | $.Nsample*($.Ncurve+1)
41 | 4
42 |
43 |
--------------------------------------------------------------------------------
/IO/standard/corrbase.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 0
4 | Struct
5 |
6 | 1
7 |
8 | 0
9 | Uint8
10 | 4
11 | 1
12 |
13 |
--------------------------------------------------------------------------------
/IO/standard/rawdatabase.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 0
4 | Struct
5 |
6 | 1
7 |
8 | 0
9 | Uint64
10 | 1
11 | 8
12 |
13 |
14 | 8
15 | Uint8
16 | 1
17 | 1
18 |
19 |
20 | 9
21 | Uint8
22 | 1
23 | 1
24 |
25 |
26 | 10
27 | Uint8
28 | 2
29 | 1
30 |
31 |
--------------------------------------------------------------------------------
/IO/standard/tube_corr_v1.0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 0
4 | Struct
5 |
6 | 1
7 |
8 | 0
9 | Uint8
10 | 4
11 | 1
12 |
13 |
14 | 4
15 | Single
16 | 4
17 | 4
18 |
19 |
20 | 20
21 | Single
22 | 1
23 | 4
24 |
25 |
26 | 24
27 | Uint32
28 | 1
29 | 4
30 |
31 |
32 | 28
33 | Single
34 | $.KVnumber
35 | 4
36 |
37 |
38 | 28+$.KVnumber*4
39 | Uint32
40 | 1
41 | 4
42 |
43 |
44 | 512
45 | Single
46 | $.Nsample*$.KVnumber*2
47 | 4
48 |
49 |
--------------------------------------------------------------------------------
/IO/struct2binfile.m:
--------------------------------------------------------------------------------
1 | function struct2binfile(S, filename, cfgtype)
2 |
3 | if nargin<3
4 | cfgtype = 'xml';
5 | end
6 |
7 | cfg = structbincfg(S);
8 | [data, ~] = packstruct(S, cfg);
9 |
10 | % output data file
11 | fid = fopen(filename,'w');
12 | fwrite(fid, data, 'uint8');
13 | fclose(fid);
14 |
15 | root = struct();
16 | root.(inputname(1)) = cfg;
17 | [pathstr, name, ~] = fileparts(filename);
18 | switch cfgtype
19 | case 'xml'
20 | xmlfile = fullfile(pathstr,[name '.xml']);
21 | struct2xml(root, xmlfile);
22 | case 'json'
23 | jsonfile = fullfile(pathstr,[name '.json']);
24 | jsonwrite(root, jsonfile);
25 | otherwise
26 | 1;
27 | end
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright Dier Zhang
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # CT-simulation
2 | # /doc/UserGuide.html
3 |
--------------------------------------------------------------------------------
/cali/calixml/Aircali_sample.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | tobefill
5 | .\IO\standard\
6 | D:\matlab\Data\cali\
7 | D:\matlab\CTsimulation\system\mod\recon\reconsystem_sample.xml
8 |
9 | 1
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | air_v1.0
19 | manutags
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/cali/calixml/Zcali_sample.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | tobefill
5 | .\IO\standard\
6 | D:\matlab\Data\cali\
7 | D:\matlab\CTsimulation\system\mod\recon\reconsystem_sample.xml
8 |
9 | 1
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/cali/calixml/corrcouple_sample.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | 1.5SecpRot
10 | 2SecpRot
11 |
12 |
13 | 0.5SecpRot, 0.8SecpRot
14 | 1SecpRot
15 |
16 |
17 |
18 |
19 |
20 |
21 | large, small
22 |
23 |
24 | 16x0.625
25 | 32x0.625
26 |
27 |
28 | 8x0.625, 4x0.625
29 | 16x0.625, 32x0.625
30 |
31 |
32 | 16x1.25, 8x1.25
33 | 32x0.625
34 |
35 |
36 | 4x1.25
37 | 8x1.25, 16x1.25, 32x0.625
38 |
39 |
40 |
--------------------------------------------------------------------------------
/cali/calixml/protocol_beamharden.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 3
4 |
5 | Static
6 | All
7 | Empty
8 | 1
9 | 1
10 | 80 100 120 140
11 | 300
12 | 300
13 | 1152
14 | 0
15 | 0
16 | 1152
17 | 500
18 | 0
19 | 0
20 | 1
21 | 0
22 | 0
23 | 0
24 | bhcali
25 | mat
26 |
27 |
28 | Body
29 |
30 |
31 | Head
32 |
33 |
--------------------------------------------------------------------------------
/cali/calixml/protocol_nonlinear.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 2
4 |
5 | Axial
6 | 16x1.0
7 | Body
8 | 1
9 | 1
10 | 120
11 | 300
12 | 30
13 | 1440
14 | 1
15 | 1
16 |
17 | 0
18 | 0
19 | 1
20 | 0
21 | 0
22 | 0
23 | nlcali
24 | mat
25 |
26 |
27 | Head
28 |
29 |
--------------------------------------------------------------------------------
/cali/experiment/loadraw_scp2.m:
--------------------------------------------------------------------------------
1 | % load raw
2 |
3 | rawpath = 'D:\data\taiying\CU\';
4 | dirpath = dir(fullfile(rawpath, '*.raw'));
5 |
6 | % Data files
7 | Data = struct();
8 | index = 1;
9 | for ii=1:length(dirpath(:))
10 |
11 | Data(index).filename = fullfile(dirpath(ii).folder, dirpath(ii).name);
12 | [~, filename_tags, ~] = fileparts(Data(index).filename);
13 | namekey = regexp(filename_tags, '_', 'split');
14 | % I know the keys are:
15 | Data(index).object = namekey{end};
16 | KV = regexp(namekey, '\d+(kv|KV)','match');
17 | KV = KV{~cellfun(@isempty, KV)};
18 | Data(index).KV = str2double(KV{1}(1:end-2));
19 | mA = regexp(namekey, '\d+ma','match');
20 | mA = mA{~cellfun(@isempty, mA)};
21 | Data(index).mA = str2double(mA{1}(1:end-2));
22 | % Data(index).bowtie = namekey{3};
23 | % Data(index).focal = namekey{3};
24 | % 2019/11/21
25 | index = index + 1;
26 | end
27 |
28 | % load data
29 | rawcfgfile = 'D:\matlab\ct\BCT16\IOstandard\rawdata_v1.0.xml';
30 | for ii = 1:length(Data)
31 | fprintf('Reading %s ...', Data(ii).filename);
32 | raw_ii = loadbindata(Data(ii).filename, rawcfgfile);
33 | Nskip = 100;
34 | Data(ii).rawmean = mean([raw_ii(Nskip+1:end).Raw_Data], 2);
35 | fprintf('done\n');
36 | end
37 |
--------------------------------------------------------------------------------
/cali/experiment/spectfitfun.m:
--------------------------------------------------------------------------------
1 | function [r, resp] = spectfitfun(x, Dp, Dair, spectrange, samplekeV, mu_ref, Dtarg, lambda)
2 |
3 | % x = normr(x);
4 | % xt = [0; abs(x(:))];
5 | % xt = [0; x(:)];
6 | xt = x(:);
7 | Nx = length(xt);
8 | t = linspace(spectrange(1), spectrange(2), Nx);
9 | % cs = spline(t, xt);
10 | % r2 = ppval(cs, C.samplekeV(:));
11 | resp = pchip(t, xt, samplekeV(:));
12 | resp(samplekeV(:) 7
20 | rr = resp(2:end-1).*2 - resp(1:end-2) - resp(3:end);
21 | r = [r; sum(rr.^2)./sum(resp.^2).*length(resp).*lambda];
22 | end
23 |
24 | end
--------------------------------------------------------------------------------
/cali/experiment/testdata/response_1219.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dier3486/CT-simulation/59b8caefab024554a6d8f7a45a0f038306115747/cali/experiment/testdata/response_1219.mat
--------------------------------------------------------------------------------
/cali/focalspot20x.m:
--------------------------------------------------------------------------------
1 | function focalspot_0x = focalspot20x(focalspot)
2 | % to explain the focalspot in protocol
3 | % focalspot_0x = focalspot20x(focalspot);
4 | % QFS: 0x10000000 (left end)
5 | % DFS: 0x01100000
6 |
7 | if isnumeric(focalspot)
8 | focalspot_0x = focalspot;
9 | else
10 | switch upper(focalspot)
11 | case 'QFS'
12 | % the 1st focal spot
13 | focalspot_0x = 1; % 0x10000000
14 | case {'DFS', 'XDFS'}
15 | % flying between 2nd and 3rd focal sopt
16 | focalspot_0x = 6; % 0x01100000
17 | case {'ZDFS'}
18 | % flying between 4th and 5th focal sopt
19 | focalspot_0x = 24; % 0x00011000
20 | otherwise
21 | % unknown focal spot
22 | focalspot_0x = 0;
23 | end
24 | end
25 |
26 | focalspot_0x = uint16(focalspot_0x);
27 |
28 | end
--------------------------------------------------------------------------------
/cali/lib/invpolyval.m:
--------------------------------------------------------------------------------
1 | function x = invpolyval(p, y, x0, lrb, tol, Nmax)
2 | % find x: y = polyval(p, x);
3 | % x = invpolyval(p, y);
4 |
5 | if nargin<3 || isempty(x0)
6 | x0 = (y-p(end))./p(end-1);
7 | x0 = fillmissing(x0, 'constant', 0);
8 | end
9 | if nargin<4
10 | lrb = [];
11 | end
12 | if nargin<5
13 | tol = 1e-6;
14 | end
15 | if nargin<6
16 | Nmax = 100;
17 | end
18 |
19 |
20 | % debug
21 | % xc = fzero(@(x) polyval(p, x)-y, x0);
22 |
23 | p = p(:)';
24 | Np = length(p);
25 | dp = (Np-1:-1:1).*p(1:end-1);
26 |
27 | alpha = 1.0;
28 |
29 | r0 = fillmissing((y-polyval(p, x0))./polyval(dp, x0), 'constant', 0);
30 | x = x0;
31 | r = r0;
32 |
33 | for ii = 1:Nmax
34 | x = x + r.*alpha;
35 | rr = r.^2;
36 | if all(rrylr(2);
54 | x(s2) = lrb(2) + (y(s2)-ylr(2))./dlr(2);
55 | end
56 |
57 | end
--------------------------------------------------------------------------------
/cali/lib/iterinvpolyval.m:
--------------------------------------------------------------------------------
1 | function y = iterinvpolyval(p, x, r, n)
2 | % return y satisfy ((((y*p(1)+1)*y*p(2)+1)*y*p(3)+1)*...)y*p(n) = x
3 | % y = iterinvpolyval(p, x, r, n);
4 |
5 | if nargin<3
6 | r = [min(x(:)./p(end)).*0.8 max(x(:)./p(end)).*1.2];
7 | end
8 | if nargin<4
9 | n = 1000;
10 | end
11 |
12 | yy = linspace(r(1), r(2), n);
13 | xx = iterpolyval(p, yy);
14 | y = interp1(xx, yy, x, 'linear', 'extrap');
15 |
16 | end
--------------------------------------------------------------------------------
/cali/lib/iterpolyval.m:
--------------------------------------------------------------------------------
1 | function y = iterpolyval(p, x)
2 | % return y = ((((x*p(1)+1)*x*p(2)+1)*x*p(3)+1)*...)*x*p(n)
3 | % y = iterpolyval(p, x);
4 |
5 | n = size(p, 2);
6 | y = ones(size(x));
7 | for ii = 1:n-1
8 | y = (y.*x).*p(:, ii) + 1.0;
9 | end
10 | y = (y.*x).*p(:, n);
11 |
12 | end
--------------------------------------------------------------------------------
/cali/lib/pinleftoptmatrix.m:
--------------------------------------------------------------------------------
1 | function [A, L, indexrange] = pinleftoptmatrix(cs, Npixel, Nslice, Nview, Npixelpermod, alpha)
2 | % subroutine used in geometric cali
3 |
4 | A = cell(Nslice, 1);
5 | indexrange = zeros(Nslice, 2);
6 | for islice = 1:Nslice
7 | pindex = [cs(islice, :).pindex];
8 | vindex = [cs(islice, :).vindex];
9 | A{islice} = sparse(vindex, pindex, double([cs(islice, :).dp]), Nview, Npixel);
10 | % cut edge
11 | edge1 = (ceil(min(pindex)/Npixelpermod) + 2)*Npixelpermod + 1;
12 | edge2 = (floor(max(pindex)/Npixelpermod) - 2)*Npixelpermod;
13 | indexrange(islice, :) = [edge1, edge2];
14 | % A{islice} = A{islice}(:, p1:p2);
15 | end
16 |
17 | % dgA = zeros(Npixel, Nslice);
18 | % L = spdiags(ones(Npixel, 1)*[-1 2 1], [-1 0 1], Npixel, Npixel);
19 | Nmod = Npixel/Npixelpermod;
20 | Lmod = cell(1, Nmod);
21 | Lvalue = repmat([-1/2 1 -1/2], Npixelpermod, 1);
22 | Lvalue(1, 2) = 1/2; Lvalue(end, 2) = 1/2;
23 | Lmod(:) = {spdiags(Lvalue, [-1 0 1], Npixelpermod, Npixelpermod)};
24 | Lall = spdiags(repmat([-1/2 1 -1/2], Npixel, 1), [-1 0 1], Npixel, Npixel);
25 | Lall(1, 1) = 1/2; Lall(end, end) = 1/2;
26 | alpha_mod = alpha(1)-alpha(2); alpha_all = alpha(2);
27 | L = blkdiag(Lmod{:}).*alpha_mod + Lall.*alpha_all;
28 | end
--------------------------------------------------------------------------------
/cali/lib/polyval2dm.m:
--------------------------------------------------------------------------------
1 | function R = polyval2dm(P, X, Y)
2 | % 2D polyvalm
3 | % R = polyval2dm(P, X, Y);
4 | % R = P(1,1) + P(2,1)*X + P(2,2)*X*Y + P(1,2)*Y + ... + P(m+1,n+1)*X^m*Y^n.
5 |
6 | [m, n] = size(P);
7 |
8 | R = zeros(size(X), 'like', X);
9 | for ix = m:-1:1
10 | yy = P(ix, n);
11 | for iy = n-1:-1:1
12 | yy = yy.*Y + P(ix, iy);
13 | end
14 | R = R.*X + yy;
15 | end
16 |
17 | end
--------------------------------------------------------------------------------
/cali/lib/polyval3dm.m:
--------------------------------------------------------------------------------
1 | function R = polyval3dm(P, X, Y, Z)
2 | % 3D polyvalm
3 | % R = polyval3dm(P, X, Y, Z);
4 | % R = P(1,1,1) + P(2,1,1)*X + P(1,2,1)*Y + P(1,1,2)*Z + ... + P(m+1,n+1,q+1)*X^m*Y^n*Z^q.
5 |
6 | [m, n, q] = size(P);
7 | R = zeros(size(X), 'like', X);
8 | yy = zeros(size(X), 'like', X);
9 | for ix = m:-1:1
10 | yy = yy.*0;
11 | for iy = n:-1:1
12 | zz = P(ix, iy, q);
13 | for iz = q-1:-1:1
14 | zz = zz.*Z + P(ix, iy, iz);
15 | end
16 | yy = yy.*Y + zz;
17 | end
18 | R = R.*X + yy;
19 | end
20 |
21 | end
--------------------------------------------------------------------------------
/cali/lib/ppcenterderivative.m:
--------------------------------------------------------------------------------
1 | function [dp, p] = ppcenterderivative(cs)
2 | % partial derivative the weight center of a spline by the node position
3 | % [dp, p] = ppcenterderivative(cs);
4 | % where the cs is the return of sline.m, e.g. cs = spline(x,[0 y 0]);
5 | % the vectorized version of this function will be used in inverse geometry calibration
6 |
7 | dx = diff(cs.breaks);
8 | dx = dx(:);
9 | X = [dx.^5./5 dx.^4./4 dx.^3./3 dx.^2./2 dx];
10 |
11 | wi = sum(cs.coefs.*X(:, 2:end), 2);
12 | ui = sum(cs.coefs.*X(:, 1:end-1), 2);
13 |
14 | w = sum(wi);
15 | c = cs.breaks(1:end-1)*wi + sum(ui);
16 |
17 | dwdx = -diff([0; wi./dx; 0]);
18 | dcdx = [wi; 0] - diff([0; wi.*cs.breaks(1:end-1)'./dx; 0]) - diff([0; ui./dx; 0]).*2;
19 |
20 | dp = (dcdx.*w - dwdx.*c)'./w^2;
21 | p = c/w;
22 |
23 | % w = sum(reshape(cs.coefs.*X(:, 2:end), [], 1));
24 | % c = cs.breaks(1:end-1)*sum(cs.coefs.*X(:, 2:end),2) + sum(reshape(cs.coefs.*X(:, 1:end-1), [], 1));
25 | % c = c/w;
26 |
27 | end
--------------------------------------------------------------------------------
/cali/lib/ppweightcenter.m:
--------------------------------------------------------------------------------
1 | function c = ppweightcenter(cs)
2 | % to find the weight center of a spline
3 | % c = ppweightcenter(cs);
4 | % where the cs is the return of sline.m, e.g. cs = spline(x,[0 y 0]);
5 |
6 | dx = diff(cs.breaks);
7 | dx = dx(:);
8 | X = [dx.^5./5 dx.^4./4 dx.^3./3 dx.^2./2 dx];
9 |
10 | w = sum(reshape(cs.coefs.*X(:, 2:end), [], 1));
11 | c = cs.breaks(1:end-1)*sum(cs.coefs.*X(:, 2:end),2) + sum(reshape(cs.coefs.*X(:, 1:end-1), [], 1));
12 | c = c/w;
--------------------------------------------------------------------------------
/cali/offfocalloadkernel.m:
--------------------------------------------------------------------------------
1 | function offcorrprm = offfocalloadkernel(offfocalkernel, protocol)
2 | % find out the coupled offfocal kernel
3 | % a hard code based on an external offfocal-kernel defination xml file
4 |
5 | offcorrprm = struct();
6 | if ~isempty(offfocalkernel)
7 | % cell to list
8 | offfocalkernel = structcellcurse(offfocalkernel);
9 | % check KV & bowtie
10 | isKV = [offfocalkernel.offfocalpara(:).KVp] == protocol.KV;
11 | isbowtie = strcmpi({offfocalkernel.offfocalpara(:).Bowtietype}, protocol.bowtie);
12 | % found any?
13 | index_cp = find(isKV & isbowtie, 1);
14 | if ~isempty(index_cp)
15 | % check collimator
16 | iscollimator = strcmp({offfocalkernel.offfocalpara(index_cp).collimation(:).collimationwidth}, ...
17 | protocol.collimator);
18 | index_colli = find(iscollimator, 1);
19 | if ~isempty(index_colli)
20 | % found
21 | offcorrprm = offfocalkernel.offfocalpara(index_cp).collimation(index_colli);
22 | end
23 | end
24 | end
25 |
26 | end
--------------------------------------------------------------------------------
/doc/UserGuide.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | CTsimulation
5 |
6 |
7 |
8 | CTsimulation User Guide
9 | Dier Zhang
10 | CTsimulation is my open source codes for CT system simulation, calibration and reconstruction.
11 |
12 |
13 |
14 |