jplbreadboard

package
v4.27.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 20, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Example (AddToSpectraLookup)
lookup := dataConvertModels.DetectorSampleByPMC{}
lookup = addToSpectraLookup(lookup,
	dataConvertModels.MetaData{
		"PMC":         dataConvertModels.IntMetaValue(123),
		"DETECTOR_ID": dataConvertModels.StringMetaValue("A"),
	},
	[]int64{1, 2, 3},
)

fmt.Printf("%+v\n", detectorsToString(lookup[123]))

lookup = addToSpectraLookup(lookup,
	dataConvertModels.MetaData{
		"PMC":         dataConvertModels.IntMetaValue(123),
		"DETECTOR_ID": dataConvertModels.StringMetaValue("B"),
	},
	[]int64{4, 5, 6},
)

fmt.Printf("%+v\n", detectorsToString(lookup[123]))

lookup = addToSpectraLookup(lookup,
	dataConvertModels.MetaData{
		"PMC":         dataConvertModels.IntMetaValue(555),
		"DETECTOR_ID": dataConvertModels.StringMetaValue("B"),
	},
	[]int64{9, 8, 7},
)

fmt.Printf("%+v\n", detectorsToString(lookup[555]))
fmt.Printf("%+v\n", detectorsToString(lookup[123]))

lookup = addToSpectraLookup(lookup,
	dataConvertModels.MetaData{
		"PMC":         dataConvertModels.IntMetaValue(123),
		"DETECTOR_ID": dataConvertModels.StringMetaValue("A"),
	},
	[]int64{7, 8, 9},
)

fmt.Printf("%+v\n", detectorsToString(lookup[555]))
fmt.Printf("%+v\n", detectorsToString(lookup[123]))
Output:

[0]meta [DETECTOR_ID:A/s PMC:123/i] spectrum [1 2 3]
[0]meta [DETECTOR_ID:A/s PMC:123/i] spectrum [1 2 3] [1]meta [DETECTOR_ID:B/s PMC:123/i] spectrum [4 5 6]
[0]meta [DETECTOR_ID:B/s PMC:555/i] spectrum [9 8 7]
[0]meta [DETECTOR_ID:A/s PMC:123/i] spectrum [1 2 3] [1]meta [DETECTOR_ID:B/s PMC:123/i] spectrum [4 5 6]
[0]meta [DETECTOR_ID:B/s PMC:555/i] spectrum [9 8 7]
[0]meta [DETECTOR_ID:A/s PMC:123/i] spectrum [1 2 3] [1]meta [DETECTOR_ID:B/s PMC:123/i] spectrum [4 5 6] [2]meta [DETECTOR_ID:A/s PMC:123/i] spectrum [7 8 9]
Example (EVCalibrationOverride)
spectrumLookup := dataConvertModels.DetectorSampleByPMC{
	1: []dataConvertModels.DetectorSample{
		dataConvertModels.DetectorSample{
			Meta:     dataConvertModels.MetaData{"PMC": dataConvertModels.IntMetaValue(1), "DETECTOR_ID": dataConvertModels.StringMetaValue("A"), "XPERCHAN": dataConvertModels.FloatMetaValue(10.4), "OFFSET": dataConvertModels.FloatMetaValue(4)},
			Spectrum: []int64{1, 10, 100},
		},
		dataConvertModels.DetectorSample{
			Meta:     dataConvertModels.MetaData{"PMC": dataConvertModels.IntMetaValue(1), "DETECTOR_ID": dataConvertModels.StringMetaValue("B")},
			Spectrum: []int64{3, 4, 5},
		},
	},
	2: []dataConvertModels.DetectorSample{
		dataConvertModels.DetectorSample{
			Meta:     dataConvertModels.MetaData{"PMC": dataConvertModels.IntMetaValue(2), "DETECTOR_ID": dataConvertModels.StringMetaValue("A"), "XPERCHAN": dataConvertModels.FloatMetaValue(6.4), "OFFSET": dataConvertModels.FloatMetaValue(-6)},
			Spectrum: []int64{20, 30, 40},
		},
		dataConvertModels.DetectorSample{
			Meta:     dataConvertModels.MetaData{"PMC": dataConvertModels.IntMetaValue(2), "DETECTOR_ID": dataConvertModels.StringMetaValue("B")},
			Spectrum: []int64{21, 22, 23},
		},
	},
}

err := eVCalibrationOverride(&spectrumLookup, 0, 0, 40, 50)

fmt.Printf("err=%v, pmcs=%v, detector counts=%v,%v\n", err, len(spectrumLookup), len(spectrumLookup[1]), len(spectrumLookup[2]))

for pmc := int32(1); pmc <= 2; pmc++ {
	for detIdx := 0; detIdx <= 1; detIdx++ {
		spec := spectrumLookup[pmc]
		//for pmc, spec := range spectrumLookup {
		//	for detIdx := range spec {
		fmt.Printf("pmc[%v][%v].Meta=%v, Spectrum=%v\n", pmc, detIdx, spec[detIdx].Meta.ToString(), spec[detIdx].Spectrum)
	}
}
Output:

err=<nil>, pmcs=2, detector counts=2,2
pmc[1][0].Meta=[DETECTOR_ID:A/s OFFSET:4/f PMC:1/i XPERCHAN:10.4/f], Spectrum=[1 10 100]
pmc[1][1].Meta=[DETECTOR_ID:B/s OFFSET:50/f PMC:1/i XPERCHAN:40/f], Spectrum=[3 4 5]
pmc[2][0].Meta=[DETECTOR_ID:A/s OFFSET:-6/f PMC:2/i XPERCHAN:6.4/f], Spectrum=[20 30 40]
pmc[2][1].Meta=[DETECTOR_ID:B/s OFFSET:50/f PMC:2/i XPERCHAN:40/f], Spectrum=[21 22 23]
Example (GetContextImagesPerPMCFromListing)
listing := []string{"../datasets/FM_5x5/P13177_5x5_190602/hk.txt", "../datasets/FM_5x5/P13177_5x5_190602/0612747347_000001C5_005048.jpg", "../datasets/FM_5x5/P13177_5x5_190602/0612756313_000001C5_005651.jpg", "../datasets/FM_5x5/P13177_5x5_190602/.DS_Store", "../datasets/FM_5x5/P13177_5x5_190602/0612744373_000001C5_004847.jpg", "../datasets/FM_5x5/P13177_5x5_190602/0612735422_000001C5_004244.jpg", "../datasets/FM_5x5/P13177_5x5_190602/0612758681_000001C5_005807.jpg", "../datasets/FM_5x5/P13177_5x5_190602/0612741400_000001C5_004646.jpg", "../datasets/FM_5x5/P13177_5x5_190602/hk_data.csv", "../datasets/FM_5x5/P13177_5x5_190602/0612732390_000001C5_004042.jpg", "../datasets/FM_5x5/P13177_5x5_190602/0612750353_000001C5_005249.jpg", "../datasets/FM_5x5/P13177_5x5_190602/0612738397_000001C5_004445.jpg", "../datasets/FM_5x5/P13177_5x5_190602/0612753334_000001C5_005450.jpg"}
results := getContextImagesPerPMCFromListing(listing, &logger.StdOutLogger{})

fmt.Printf("length: %d\n", len(results))

// Print in sorted order so we match output (go maps may not be storing these in ascending PMC order)
lines := []string{}
for k, v := range results {
	lines = append(lines, fmt.Sprintf("[%d]=%v", k, v))
}

sort.Strings(lines)
for _, l := range lines {
	fmt.Println(l)
}
Output:

length: 10
[4042]=0612732390_000001C5_004042.jpg
[4244]=0612735422_000001C5_004244.jpg
[4445]=0612738397_000001C5_004445.jpg
[4646]=0612741400_000001C5_004646.jpg
[4847]=0612744373_000001C5_004847.jpg
[5048]=0612747347_000001C5_005048.jpg
[5249]=0612750353_000001C5_005249.jpg
[5450]=0612753334_000001C5_005450.jpg
[5651]=0612756313_000001C5_005651.jpg
[5807]=0612758681_000001C5_005807.jpg
Example (GetMSASeqNo)
names := []string{"file0001.msa", "file_0001.msa", "file_1.txt", "Normal_A_0612673072_000001C5_000013.msa", "Normal_A_0612673072_000001C5_0033213.msa", "Some_Thing_With_Spectra_16.msa", "../Path_With/Underscores/Some_Thing_With_Spectra_43.msa"}

for _, name := range names {
	s, e := getMSASeqNo(name)
	fmt.Printf("%v|%v\n", s, e)
}
Output:

0|Invalid MSA file name: file0001.msa
1|<nil>
0|Unexpected file extension when reading MSA: .txt
13|<nil>
33213|<nil>
16|<nil>
43|<nil>
Example (GetSpectraFiles)
files := []string{"../something/file.txt", "../something/Normal_B_1_2_3.msa", "../something/BulkSum_B_1_2_3.msa", "../something/Another_B_1_2_3.msa", "../something/Normal_B_1_2.jpg", "Normal_P_1_2_3.msa"}
f, l := getSpectraFiles(files, true, &logger.StdOutLogger{})

for _, v := range f {
	fmt.Printf(v + "\n")
}

for _, v := range l {
	fmt.Printf(v + "\n")
}
Output:

../something/Normal_B_1_2_3.msa
../something/BulkSum_B_1_2_3.msa
Normal_P_1_2_3.msa
Ignoring extension '.txt' in: ../something/file.txt
unexpected MSA read type
Ignoring extension '.jpg' in: ../something/Normal_B_1_2.jpg
Example (GetSpectraReadType)
names := []string{
	"Normal_A_0612673072_000001C5_000013.msa",
	"Dwell_A_0612673072_000001C5_000013.msa",
	"MaxValue_A_0612729542_000001C5_004040.msa",
	"BulkSum_B_0612729540_000001C5_004040.msa",
	"File1.msa",
	"File.txt",
	"Average_B_0612729540_000001C5_004040.msa",
}

for _, name := range names {
	s, e := getSpectraReadType(name)
	fmt.Printf("%v|%v\n", s, e)
}
Output:

Normal|<nil>
Dwell|<nil>
MaxValue|<nil>
BulkSum|<nil>
|unexpected MSA filename when detecting read type
|unexpected MSA filename when detecting read type
|unexpected MSA read type
Example (MakeBulkMaxSpectra)
spectrumLookup := dataConvertModels.DetectorSampleByPMC{
	1: []dataConvertModels.DetectorSample{
		{
			Meta:     dataConvertModels.MetaData{"PMC": dataConvertModels.IntMetaValue(1), "DETECTOR_ID": dataConvertModels.StringMetaValue("A"), "XPERCHAN": dataConvertModels.FloatMetaValue(10.4), "OFFSET": dataConvertModels.FloatMetaValue(4)},
			Spectrum: []int64{1, 10, 100},
		},
		{
			Meta:     dataConvertModels.MetaData{"PMC": dataConvertModels.IntMetaValue(1), "DETECTOR_ID": dataConvertModels.StringMetaValue("B"), "LIVETIME": dataConvertModels.FloatMetaValue(9.5)},
			Spectrum: []int64{3, 4, 5},
		},
	},
	2: []dataConvertModels.DetectorSample{
		{
			Meta:     dataConvertModels.MetaData{"PMC": dataConvertModels.IntMetaValue(2), "DETECTOR_ID": dataConvertModels.StringMetaValue("A"), "XPERCHAN": dataConvertModels.FloatMetaValue(6.4), "OFFSET": dataConvertModels.FloatMetaValue(-6), "LIVETIME": dataConvertModels.FloatMetaValue(8.5)},
			Spectrum: []int64{20, 30, 40},
		},
		{
			Meta:     dataConvertModels.MetaData{"PMC": dataConvertModels.IntMetaValue(2), "DETECTOR_ID": dataConvertModels.StringMetaValue("B"), "LIVETIME": dataConvertModels.FloatMetaValue(10)},
			Spectrum: []int64{21, 22, 23},
		},
	},
}

pmc, data := makeBulkMaxSpectra(spectrumLookup, 0, 0, 40, 50)

fmt.Printf("pmc=%d, len=%d\n", pmc, len(data))
fmt.Printf("[0]=%+v\n", data[0].ToString())
fmt.Printf("[1]=%+v\n", data[1].ToString())
fmt.Printf("[2]=%+v\n", data[2].ToString())
fmt.Printf("[3]=%+v\n", data[3].ToString())
Output:

pmc=3, len=4
[0]=meta [DETECTOR_ID:A/s LIVETIME:8.5/f OFFSET:-1/f PMC:3/i READTYPE:BulkSum/s SOURCEFILE:GeneratedByPIXLISEConverter/s XPERCHAN:8.4/f] spectrum [21 40 140]
[1]=meta [DETECTOR_ID:B/s LIVETIME:19.5/f OFFSET:50/f PMC:3/i READTYPE:BulkSum/s SOURCEFILE:GeneratedByPIXLISEConverter/s XPERCHAN:40/f] spectrum [24 26 28]
[2]=meta [DETECTOR_ID:A/s LIVETIME:8.5/f OFFSET:-1/f PMC:3/i READTYPE:MaxValue/s SOURCEFILE:GeneratedByPIXLISEConverter/s XPERCHAN:8.4/f] spectrum [20 30 100]
[3]=meta [DETECTOR_ID:B/s LIVETIME:9.75/f OFFSET:50/f PMC:3/i READTYPE:MaxValue/s SOURCEFILE:GeneratedByPIXLISEConverter/s XPERCHAN:40/f] spectrum [21 22 23]

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MSATestData

type MSATestData struct {
}

func (MSATestData) Import

func (m MSATestData) Import(importPath string, pseudoIntensityRangesPath string, datasetID string, jobLog logger.ILogger) (*dataConvertModels.OutputData, string, error)

Import - Implementing Importer interface, expects importPath to point to a directory containing importable files, with an import.json

containing fields specific to this importer

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL