-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
export ok, background correction started
- Loading branch information
1 parent
96cf56e
commit de4306d
Showing
4 changed files
with
126 additions
and
47 deletions.
There are no files selected for viewing
81 changes: 81 additions & 0 deletions
81
volker/toolsets/measure_intensity_without_spots/conversion.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import os | ||
from ij import ImagePlus | ||
from ij import ImageStack | ||
from ij.io import FileSaver | ||
from ij.plugin import RGBStackMerge | ||
from loci.plugins import BF | ||
from loci.plugins.in import ImporterOptions | ||
from loci.formats import ImageReader | ||
|
||
|
||
class BFWellsSeriesToTifStackSeries(object): | ||
|
||
|
||
def __init__(self, path): | ||
self.inputPath = path | ||
self.outputFolderName = "export" | ||
|
||
|
||
def setOutputFolderName(self, name): | ||
self.outputFolderName = name | ||
|
||
|
||
def getOutputPath(self): | ||
outputPath = os.path.join(os.path.dirname(self.inputPath), self.outputFolderName) | ||
if not os.path.exists(outputPath): | ||
os.makedirs(outputPath) | ||
return outputPath | ||
|
||
|
||
def getNumberOfChannels(self): | ||
reader = ImageReader() | ||
reader.setId(self.inputPath) | ||
nrOfChannels = reader.getSizeC() | ||
return nrOfChannels | ||
|
||
|
||
def getOptions(self): | ||
options = ImporterOptions() | ||
options.setId(self.inputPath) | ||
options.setOpenAllSeries(True) | ||
options.setSplitChannels(True) | ||
return options | ||
|
||
|
||
def getImages(self): | ||
images = list(BF.openImagePlus(self.getOptions())) | ||
width = images[0].getWidth() | ||
height = images[0].getHeight() | ||
return images, width, height | ||
|
||
|
||
def run(self): | ||
nrOfChannels = self.getNumberOfChannels() | ||
options = self.getOptions() | ||
images, width, height = self.getImages() | ||
cStacks = [None]*nrOfChannels | ||
for c in range(nrOfChannels): | ||
cStacks[c] = ImageStack(width, height) | ||
lastWell = None | ||
title = "" | ||
cImages = [None]*nrOfChannels | ||
for c in range(nrOfChannels): | ||
cImages[c] = [image for i, image in enumerate(images) if i%2==c] | ||
for cImageTupel in zip(*cImages): | ||
title = cImageTupel[0].getTitle() | ||
calibration = cImageTupel[0].getCalibration() | ||
well = title.split("Well ")[1].split(" Field")[0] | ||
if well == lastWell or lastWell==None: | ||
for c in range(nrOfChannels): | ||
cStacks[c].addSlice(cImageTupel[c].getProcessor()) | ||
else: | ||
imagesC = [ImagePlus(title.replace("C=0", "C=" + str(c)), cStacks[c]) for c in range(nrOfChannels)] | ||
resultImage = RGBStackMerge.mergeChannels(imagesC, False) | ||
resultImage.setCalibration(calibration) | ||
saver = FileSaver(resultImage) | ||
print(os.path.join(self.getOutputPath(), title.replace(" - C=0", ""))) | ||
saver.saveAsTiffStack(os.path.join(self.getOutputPath(), title.replace(" - C=0", ""))) | ||
cStacks = [None]*nrOfChannels | ||
for c in range(nrOfChannels): | ||
cStacks[c] = ImageStack(width, height) | ||
lastWell = well |
11 changes: 11 additions & 0 deletions
11
volker/toolsets/measure_intensity_without_spots/correct_background.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from ij import IJ | ||
|
||
CHANNEL = 2 | ||
LAMBDA_FLAT = 0.50 | ||
LAMBDA_DARK = 0.50 | ||
image = IJ.getImage() | ||
width, height, nChannels, nSlices, nFrames = image.getDimensions() | ||
spotsChannelImage = Duplicator().run(image, CHANNEL, CHANNEL, 1, nSlices, 1, nFrames) | ||
title = spotsChannelImage.getTitle() | ||
IJ.run(spotsChannelImage, "BaSiC ", "processing_stack=[" + spotsChannelImage.getTitle() + "] flat-field=None dark-field=None shading_estimation=[Estimate shading profiles] shading_model=[Estimate both flat-field and dark-field] setting_regularisationparametes=Automatic temporal_drift=[Replace with zero] correction_options=[Compute shading and correct images] lambda_flat=" + LAMBDA_FLAT + " lambda_dark=" + LAMBDA_DARK) | ||
IJ.selectImage() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters