Exemplo n.º 1
0
def read_sted_stacks_from_imspector_measurement(file_path):
    """
    Mit Hilfe von Sarah und aufgrund der vielen Probleme mit den Stacks hier die komplizierte Formel um die MitoStacks
    herauszuholen. Eigentlich heißen die Stacks "Alexa 594_STED" aber halt nicht immer...
    """

    # File lesen
    im_file = sp.File(file_path, sp.File.Read)
    number_stacks = im_file.number_of_stacks()

    # lese alle stacks in eine liste
    stacks = []
    for i in range(number_stacks):
        stack = im_file.read(i)
        stacks.append(stack)

    sted_stacks = [
        stack for stack in stacks
        if " " not in stack.name() or "STED" in stack.name()
        or "Ch2 {2}" in stack.name() or "Ch4 {2}" in stack.name()
    ]

    # if we get more than 2 stacks (one AF594 and one STAR RED) then it's most likely duplicates and we will just remove them from the list
    if len(sted_stacks) > 2:
        sted_stacks = sted_stacks[:2]

    # now super special: if the file path contains '04_U2OS_DKO_plus_Bax_BH3i/replicate1/pcDNA', then the Mito and Bax channel are exchanged (antibodies exchanged or so... ask Sarah)
    if '04_U2OS_DKO_plus_Bax_BH3i/replicate1/pcDNA' in file_path:
        sted_stacks.reverse()

    return sted_stacks
Exemplo n.º 2
0
def read_stack_from_imspector_measurement(file_path):
    """
    Lädt die Imspector Messung und findet die Kanäle (=stacks) die wir mit namepart sepzifizieren.

    :param file_path: Pfad der Imspector Messung.
    :param name_part: Teil des Stacknamens
    :return: Alles Kanäla (=Stacks), die so heißen
    """

    # File lesen
    measurement = specpy.File(file_path, specpy.File.Read)

    # lese alle stacks in eine liste
    all_stacks = []  #empty list
    number_stacks = measurement.number_of_stacks(
    )  # returns the number of stacks in the measurement
    for i in range(number_stacks):
        stack = measurement.read(
            i)  #ein Kanal wird in Imspector als stack bezeichnet!
        all_stacks.append(stack)
    print('The measurement contains {} channels.'.format(
        len(all_stacks)))  # gibt mir aus wie viele Kanäle die Messung hat

    # finde alle stacks, deren name entweder das Wort STED enthält, oder welcher keine spaces (EMPTY) enthält, das kann dann nur der leere (=duplizierte) sein.
    # die CONSTANTS dafür sind oben vor der main() definiert = workaround für channel duplication und bescheuerte ImSpector Benennungen..
    wanted_stack_s = [
        stack for stack in all_stacks if EMPTY not in stack.name()
        or STED in stack.name() or CH2 in stack.name() or CH4 in stack.name()
    ]  # list comprehension(?)  #stack.name() ist von specpy
    print('The measurement contains {} STED channels.'.format(
        len(wanted_stack_s)))

    # if we get more than 2 stacks (one AF594 and one STAR RED) then it's most likely duplicates and we will just remove them from the list
    if len(wanted_stack_s) > 2:
        wanted_stack_s = wanted_stack_s[:2]

    #OR: wanted_stack_s[:min(len(wanted_stack_s), 2)]  # this gives back the wanted_stack_s list from the start up until before 2 (so 0 and 1).
    #However, if the stack is smaller then it should only return up until the length of the list, otherwise we will get an index error.
    #that's why we need the minimum of the two values. Either length of list or 2.

    return wanted_stack_s
Exemplo n.º 3
0
def read_stack_from_imspector_measurement(file_path, name_part):
    """
    Lädt Stacks aus einer Imspector Messung.

    :param file_path: Pfad der Imspector Messung.
    :param name_part: Teil des Stacknamens
    :return: Alles Stacks, die so heißen
    """

    # File lesen
    im_file = sp.File(file_path, sp.File.Read)
    number_stacks = im_file.number_of_stacks()

    # lese alle stacks in eine liste
    stacks = []
    for i in range(number_stacks):
        stack = im_file.read(i)
        stacks.append(stack)

    # finde allen stacks, deren name name_part enthält
    stacks = [stack for stack in stacks if name_part in stack.name()]

    return stacks
"""

import os
import specpy as sp
import numpy as np
import matplotlib.pyplot as plt

# alle Einstellungen
root_path = r'Q:\00_Users\Sarah Schweighofer (sschwei)\Freiburg\IF36_selected-for-analysis-with-Jan'
file_path = os.path.join(
    root_path,
    'IF36_spl15_U2OS-DKO_pcDNA-Bax-wt_6hEx_14hAct_cytC-AF488_Tom20-AF594_Bax-SR_cl8_ringheaven.msr'
)

# File lesen
im_file = sp.File(file_path, sp.File.Read)
number_stacks = im_file.number_of_stacks()
print('Messung {} hat {} Bilder.'.format(file_path, number_stacks))

# alle Stacks lesen
# if False:
for i in range(number_stacks):
    stack = im_file.read(i)
    # print('Stack {} ist {}D mit der Größe {}'.format(stack.name(), stack.number_of_dimensions(), stack.sizes()))

    # ist es der STED BAX Kanal?
    if stack.name().startswith('STAR RED_STED'):
        # Ja
        data = stack.data()

        # Dimensionnen sind [1,1,Ny,Nx] wir wollen aber [Nx, Ny]
  Sarah probiert herum
"""

import os
import specpy as sp
import numpy as np
import matplotlib.pyplot as plt

# alle Einstellungen
root_path = r'Q:\00_Users\Sarah Schweighofer (sschwei)\Freiburg\IF36_selected-for-analysis-with-Jan'
file_name = 'IF36_spl15_U2OS-DKO_pcDNA-Bax-wt_6hEx_14hAct_cytC-AF488_Tom20-AF594_Bax-SR_cl8_ringheaven.msr'
file_path = os.path.join(root_path, file_name)


# File lesen
im_file = sp.File(file_path, sp.File.Read) #sp. sagt ihm, dass die Funktion aus dem Package kommt, warum brauch ich das?
number_stacks = im_file.number_of_stacks() #hier darf ich das sp. nicht hinzufügen - warum?
print('Messung {} hat {} Bilder.'.format(file_name, number_stacks))
'''#zwei geschwungene Klammern brauchen zwei Variablen
#mit der .format Funktion kann man in nem String geschwungene Klammern als Platzhalter lassen und die Variablen danach
#einsetzen
# Das wäre die Deppen-Version: print("Messung " + str(file_name) + "hat " + str(number_stacks) + ".")
'''

# alle Stacks/Kanäle lesen
for i in range(number_stacks):
    stack = im_file.read(i)
    '''
    # für die Anzahl an Stacks (Bei Abberior ist ein Kanal automatisch immer ein Stack) geht
    # er durch und liest die einzelnen Kanäle ein und jedes dieser Elemente hat dann den Namen stack.
    # Diese .read Funktion ist aber was anderes als die .Read Funktion von SpecPy, richtig?