code: def calculate_ec50(conc, responses, Logarithmic):
      """EC50 Function to fit a dose-response data to a 4 parameter dose-response
      curve.
  
      Inputs: 1. a 1 dimensional array of drug concentrations
              2. the corresponding m x n array of responses
      Algorithm: generate a set of initial coefficients including the Hill
                 coefficient
                 fit the data to the 4 parameter dose-response curve using
                 nonlinear least squares
      Output: a matrix of the 4 parameters
              results[m,1]=min
              results[m,2]=max
              results[m,3]=ec50
              results[m,4]=Hill coefficient
  
      Original Matlab code Copyright 2004 Carlos Evangelista
      send comments to CCEvangelista@aol.com
      """
      # If we are using a log-domain set of doses, we have a better chance of
      # fitting a sigmoid to the curve if the concentrations are
      # log-transformed.
      if Logarithmic:
          conc = numpy.log(conc)
  
      n = responses.shape[1]
      results = numpy.zeros((n, 4))
  
      def error_fn(v, x, y):
          """Least-squares error function
  
          This measures the least-squares error of fitting the sigmoid
          with parameters in v to the x and y data.
          """
          return numpy.sum((sigmoid(v, x) - y) ** 2)
  
      for i in range(n):
          response = responses[:, i]
          v0 = calc_init_params(conc, response)
          v = scipy.optimize.fmin(
              error_fn,
              v0,
              args=(conc, response),
              maxiter=1000,
              maxfun=1000,
              disp=False,
          )
          results[i, :] = v
      return results
  
imports: import functools
  import os
  import numpy
  import scipy.optimize
  from cellprofiler_core.constants.measurement import EXPERIMENT
  from cellprofiler_core.constants.measurement import IMAGE
  from cellprofiler_core.constants.measurement import NEIGHBORS
  from cellprofiler_core.constants.module import IO_FOLDER_CHOICE_HELP_TEXT, IO_WITH_METADATA_HELP_TEXT
  from cellprofiler_core.measurement import Measurements
  from cellprofiler_core.module import Module
  from cellprofiler_core.preferences import ABSOLUTE_FOLDER_NAME
  from cellprofiler_core.preferences import DEFAULT_INPUT_FOLDER_NAME
  from cellprofiler_core.preferences import DEFAULT_INPUT_SUBFOLDER_NAME
  from cellprofiler_core.preferences import DEFAULT_OUTPUT_FOLDER_NAME
  from cellprofiler_core.preferences import DEFAULT_OUTPUT_SUBFOLDER_NAME
  from cellprofiler_core.setting import Binary
  from cellprofiler_core.setting import Divider
  from cellprofiler_core.setting import Measurement
  from cellprofiler_core.setting import SettingsGroup
  from cellprofiler_core.setting import ValidationError
  from cellprofiler_core.setting.do_something import DoSomething
  from cellprofiler_core.setting.do_something import RemoveSettingButton
  from cellprofiler_core.setting.text import Directory
  from cellprofiler_core.setting.text import Text
label_desc: Use image node_id 5 for calling a global function with example usage: calculate_ec50(conc, responses, Logarithmic) and returns: results, numpy